feat: keep parent formatters bindings function option #1950
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Synopsis
I have the following code, which intent to make some property values upper case (it could also be stringified, etc.):
When I run this code, I actually get the following output:
Shape the
bindings
passed to thechild()
methodThere are currently functions to shape the log
level
, thelog
object, thebindings
, but I cannot see any function to shape the bindings passed to a child logger through thechild()
method.I would like to be able to apply my shaping function to the
partner
property:Keep the parent
bindings
formatters function in children loggersIn case of a global
bindings
formatters function, I would like to be able to keep thatbindings
formatters function in the logger children (and without having to pass it at eachchild()
call).I would like to be able to apply my shaping function to all my
propertyPaths
properties in my logger children too, so I can get the following:Proposal
Add an
options
objectAdd a formatters
options
object, with akeepParentBindings
option:The formatters
options
object would be passed to the child loggers, except if a newoptions
object is passed to thechild()
method.The
keepParentBindings
optionIf
true
, child loggers will keep their parentbindings
formatters function.If
false
orundefined
, child loggers will have theirbindings
formatters function reset to a "no-op" formatter function, as today.The
child()
methodIn the
child()
method, the parentbindings
function will be passed or not to the child logger according to thekeepParentBindings
option, except if a newbindings
formatters function is passed to the child logger.