-
Notifications
You must be signed in to change notification settings - Fork 2
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
Fix logging #9
Fix logging #9
Conversation
@hriebl Since pytests |
Thank you very much for looking into this, @jobrachem! This PR helps me to understand the logging module a lot better. The question I'm wondering about is if we really want to have a non-propagating logger, because that would make the configuration a lot harder. Say we wanted to log the messages from both JAX and Liesel to one file, then we'd need to set the same file handler for two loggers. Or if we wanted to apply the same formatting to all messages, we'd need to adjust the formatter for two handlers of two loggers. Here's the output of a small experiment on my system:
So, JAX seems to add a stream handler to |
You raise some very good points I think. Especially
The only reason that I see why we are adding a handler in the
If we go with option 1, we need to make it work with existing loggers, either by turning propagation of the liesel logger off or by dealing with existing handlers in a clever way. Intuitively, the latter seems a little risky to me, because we might start to see weird behavior depending on what other libraries do. Option 2 may be easier and code-wise cleaner than option 1. It also conforms to advice given in the documentation for the Interestingly, the very thing that messes with our logging seems to be the fact that jax or one of its dependencies started adding a handler to the root logger. In v0.3.13, this was apparently not the case:
|
@hriebl I added the |
adding a logger to root is not recommended (if i understood you correctly). should we create an issue concerning the issue in the jax repo? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thank you for the latest changes, @jobrachem! Merging.
This PR fixes the questionable behavior of changing the root logger's settings.
It also adds the current logger's name to the output of Liesel's log messages. This will allow users to identify the exact logger that is responsible for individual messages, such that those exact loggers can be edited more easily.