-
-
Notifications
You must be signed in to change notification settings - Fork 21
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
Has setup_logging not override already setup loging level. #132
base: main
Are you sure you want to change the base?
Conversation
I'm not sure I like the fact that this makes the WDYT? |
Yeah, if you want to push further improvement I'm all for it. feel free to push on my branch. Alternative is to have set_log_level unconditionally a context manager. |
Okay I pushed my changes here. |
So now I think we should expose |
I see how those can be useful as long as they temporarily increase/decrease level and the default is to no change. IMHO verbose=None|False|True is ment for end user, while setting to level like Regardless it's up to you. |
micropip/logging.py
Outdated
def setup_logging(verbosity: int | bool | None) -> LoggerWrapper: | ||
_set_formatter_once() | ||
assert _logger | ||
result = LoggerWrapper(_logger) |
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.
I think this is still wrong, as this changes the logging level permanently for a logger wrapper even if passed None.
I think the conflation of getting a logger and setting the level is creating issues.
Add a verbosity=None (and make it the default) for verbosity. If one has already increase the logging level, the default value of verbose should not change it. This is achieved with a default value of None. Technically I guess we should have a context manager to restaure previous value if True/False is passed, but that will be for another time. I also think that if verbosity is an int, we should set the lgging level to that int instead of havin an arbitrary verbosity of 0/1/2; but that's also another discussion. I'm doing this as I'd like adding some logger.debug, but I don't want to pass verbose=True everywhere. Restore logger level between calls forward getattr/setattr unconditional context manager
Thanks for your patience, and sorry I was on PTO. Back at this again; as setup_logging is used only in 2 places I think it's ok to have a bigger change on API.
All two usages are now using this new API, this so install and uninstall should behave the same, except if the level is changed outside of those calls, it stay changed. (still waiting for the tests to pass, and strongly suggest looking at diff with whitespace removed from the GitHub option, as large changes are just indent of function bodies. |
Add a verbosity=None (and make it the default) for verbosity. If one has already increase the logging level, the default value of verbose should not change it. This is achieved with a default value of None.
Technically I guess we should have a context manager to restaure previous value if True/False is passed, but that will be for another time.
I also think that if verbosity is an int, we should set the lgging level to that int instead of havin an arbitrary verbosity of 0/1/2; but that's also another discussion.
I'm doing this as I'd like adding some logger.debug, but I don't want to pass verbose=True everywhere.