-
Notifications
You must be signed in to change notification settings - Fork 861
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
level-change event fired when child is created #1006
Comments
It happens because we need to set the level on the child instance: Line 124 in 84fa44b
Which in turn invokes: Lines 84 to 111 in 84fa44b
I suppose an optional second parameter can be passed to signal omitting the event. |
I think this is a bug, as we should call reinitialize the EventEmitter state when creating a child. However, I'm not sure this is worth the overhead! |
Well, I guess at least it's worth to document it, since I was quite surprised to see those events polluting logs (even though I've solved it with simple if newVal !== prevVal in my handler) |
If you would like to try fixing it, I'd welcome a PR. The problem is caused by child loggers "inheriting" their parent event listeners. |
A PR updating the doc is also fine. |
@mcollina wouldn't it be effectively a breaking change if child loggers WON'T inherit event listeners though? I believe someone could rely on this functionality. |
version numbers are there to be bumped. We have the next branch that we accumulate all our breaking changes and then ship them. |
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs. |
When I create a child instance of a logger,
level-change
event is fired. This, for example, causes 2 events per request inpino-http
(can provide simple repro). I am not sure if it's desired behaviour, since it isn't described in the documentation and can be a bit confusing. If it is a desired behaviour, I can help expanding the documentation.Example code:
Output:
The text was updated successfully, but these errors were encountered: