-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Combine child metadata with additional metadata #1864
Comments
I just ran into this problem too, and I can see what is causing it. In the logger.js file, the child's write method override gets an
should be
The readme clearly says, "You can create child loggers from existing loggers to pass metadata overrides," so I'd expect my object to override the defaultMeta defined in the parent logger. https://github.com/winstonjs/winston#creating-child-loggers |
I made a PR and ran the unit tests. It wasn't as straightforward as rearranging the Object.assign() calls because there are use cases when you call |
@aressler38 I took a more radical and seemingly consistent approach in #1879. Reused your test though. |
Pretty sure the maintainers have abandoned the project. I've had a PR in the works for this same issue for a very long time. #1598 I've thought about publishing my fork of the project and moving it forward but I don't personally have the time to commit to the project as it currently stands. |
Closing as this issue is being consolidated into #2029 |
I'm not sure this is a bug or feature request. I'll use the bug template since it also contains the behavior I'd expect.
Please tell us about your environment:
winston
version?winston@2
winston@3
node -v
outputs: v12.14.0What is the problem?
There seems to be no way to combine child metadata with additional properties.
In fact, I find the multiple api signatures in which one can log a message to be quite conflicting/confusing.
For example, consider this code:
All of these are valid, but produce different/unexpected results:
What do you expect to happen instead?
I can't really find an api reference, so it's hard to know what is to be expected and what not.
But I would expect that when I create a child logger with metadata, the metadata acts in the way the default metadata on the logger works. Because now, there is no way to add in additional properties in a log call, without losing the metadata passed in to the child logger.
So I would expect that I can still call
childLogger.log('info', 'message', { additionalProp: 'foo' })
and still have theprefix=child
property in the metadata. And in fact, I would expect this to be the case for any of the example calls to childLogger.The text was updated successfully, but these errors were encountered: