Python 3: fix logging level not being updated correctly - #9809
Merged
michaelDCurran merged 1 commit intoJun 25, 2019
Conversation
michaelDCurran
approved these changes
Jun 25, 2019
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Link to issue number:
Fixes #9807
Summary of the issue:
Changing the log level on a running copy of NVDA with Python 3 doesn't have much effect.
We have been creating our logger instance in a way the Python docs discourage. They encourage a user to initialize a logger using logging.getLogger.
This wasn't a problem on Python 2. However, in python 3, isEnabledFor uses an internal cache for the enabled levels. This cache is cleared by the log manager, howver, as we didn't create our logger using the official route, the log manager didn't know about our logger and therefore didn't clear the logger cache.
Description of how this pull request fixes the issue:
Before creating a logger, we make our logger class the default class using logging.setLoggerClass. Then, we create an instance using logging.getLogger.
Testing performed:
Tested that log level changes as expected and debug logging works as expected.
Known issues with pull request:
As our Logger class is now the default logger class, all other loggers, particularly comtypes, now also use our it. I don't think that should be a problem though, since our class extends on the default class.
Change log entry:
None