Skip to content

Python 3: fix logging level not being updated correctly - #9809

Merged
michaelDCurran merged 1 commit into
nvaccess:threshold_py3_stagingfrom
LeonarddeR:py3_fixLogging
Jun 25, 2019
Merged

Python 3: fix logging level not being updated correctly#9809
michaelDCurran merged 1 commit into
nvaccess:threshold_py3_stagingfrom
LeonarddeR:py3_fixLogging

Conversation

@LeonarddeR

Copy link
Copy Markdown
Collaborator

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

@michaelDCurran
michaelDCurran merged commit 8acc736 into nvaccess:threshold_py3_staging Jun 25, 2019
@nvaccessAuto nvaccessAuto added this to the 2019.3 milestone Jun 25, 2019
@LeonarddeR
LeonarddeR deleted the py3_fixLogging branch August 23, 2025 06:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants