patronum
patronum copied to clipboard
Add custom names support for `debug`
Sometimes it is needed to log some unit updates with custom naming, so it is easier to read them in context
It can be simply achieved by using object shape:
debug({
brokenStore: $a,
someEvent: abc
})
debug({
trace: true
}, {
brokenStore: $a,
someEvent: abc
})
Keys of the object will be treated as custom names for these units
Also there is maybe a need to provide custom name for some unit, which is logged not directly, but via tracing:
const $abc = combine([$a, $b, $c])
sample({
clock: $abc,
target: someEvent
})
debug({
trace: true,
names: {
customStoreName: $abc,
}
}, someEvent)
// debug will log someEvent's updates traces with $abc named as customStoreName
I think the first form can be error-prone because it conflicts with the first argument as a config.
debug({
brokenStore: $a,
someEvent: abc,
})