-
Notifications
You must be signed in to change notification settings - Fork 153
Bug: LogFormatter not forwarded to child loggers #1264
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
Comments
Hello @ghdoergeloh, thank you for opening the issue. I think it is a bug since the child should have all the parent's attributes, except you overwrite them with I made a quick fix, but I want to revisit other attributes that may be also missed for children. Then I open a PR. @dreamorosi assign me, please. This is also part of #483. |
While I see the validity of the arguments presented, I'd like us to evaluate first if this would be a breaking change and the potential impact for developers by changing this behaviour now in their production environments. Let us look into it first. |
@saragerion sure! For context, we changed the implementation of child logger in #1178 last year |
So, I have been thinking about this and after reading the documentation & docstrings of the method ( On a high level, and without context, when we create a child logger we want to create a new instance of this logger that is exactly the same as its parent, except for any override that is explicitly set during creation. The docstring for the method reads this (emphasis mine):
The docs instead, state this (emphasis mine):
The wording of both pieces of documentation suggests that the parent and child should be exactly the same, except for any explicit override. With the above in mind, I would expect the I do see however an opportunity to further flash out the wording in the docs to make it extra clear that all attributes and settings are forwarded - as identical might not be enough. |
|
A fix was released as part of the latest v1.6.0 release. |
Use case
I found out, that I need to pass the LogFormatter to every child. It would be nice to forward the parents LogFormatter as the default to a child logger (via createChild) if no other LogFormatter was provided in that method.
Solution/User Experience
So if logger.createChild({}) is called without logFormatter it could just get the same instance, the parent is using.
Alternative solutions
No response
Acknowledgment
The text was updated successfully, but these errors were encountered: