You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You can create child loggers from existing loggers to pass metadata overrides
But the metadata specified in defaultMeta in createLogger is not overridden.
What do you expect to happen instead?
I expect the metadata (options) provided to the child logger to override the defaultMeta provided in an upstream logger
Other information
Looking at the Logger class (logger.js; Line 58), the write method overridden by the child uses Object.assign() to merge the info and child metadata objects, but they appear to be in the wrong order.
Also documentation about child loggers is poor. It has no example of using defaultMeta usage in log messages and there is no child logger examples in examples folder.
I am having this same problem. Is there a reason why this hasn't been fixed already? Seems like a very simple PR to swap the order of requestDefaultMetadata and info.
Please tell us about your environment:
winston
version?winston@2
winston@3
node -v
outputs:v13.13.0
Linux
TypeScript 3.8
What is the problem?
The documentation states:
But the metadata specified in
defaultMeta
increateLogger
is not overridden.What do you expect to happen instead?
I expect the metadata (options) provided to the child logger to override the
defaultMeta
provided in an upstream loggerOther information
Looking at the Logger class (logger.js; Line 58), the
write
method overridden by the child usesObject.assign()
to merge the info and child metadata objects, but they appear to be in the wrong order.https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/assign#Merging_objects_with_same_properties
defaultRequestMetadata
should come afterinfo
in the sources list to allow for child metadata to override the parent logger's metadata.The text was updated successfully, but these errors were encountered: