This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author David Wang
Recipients David Wang
Date 2019-06-12.21:48:28
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1560376108.37.0.126278550075.issue37258@roundup.psfhosted.org>
In-reply-to
Content
If you call setLevel() on a subclass of logging.Logger, it does not reset the cache for that logger. This mean that if you make some logging calls, then call setLevel(), the logger still acts like it still has its old level. See the attached python file for a reference.

Currently, the user has to call logger._cache.clear() to manually clear the cache after calling setLevel(). To fix this in Python, we would have to change Logger.setLevel() in /logging/__init__.py to have the following code
```
self.level = _checkLevel(level)
self.manager._clear_cache()
self._cache.clear()
```

Note the following:
- I made sure the subclass has a handler attached so setLevel() should work
- This bug does not occur if you use logging.getLogger(). This is because logging.getLogger() returns the root logger, and the cache clear specifically targets the root logger's cache to be cleared. It occurs when the logger is specifically subclassed from logging.getLoggerClass()
- The cache was added in Python 3.7, so this bug is specific to this version of python.
History
Date User Action Args
2019-06-12 21:48:28David Wangsetrecipients: + David Wang
2019-06-12 21:48:28David Wangsetmessageid: <1560376108.37.0.126278550075.issue37258@roundup.psfhosted.org>
2019-06-12 21:48:28David Wanglinkissue37258 messages
2019-06-12 21:48:28David Wangcreate