mirror of
https://github.com/python/cpython.git
synced 2025-08-31 14:07:50 +00:00
bpo-33606: improve logging performance when logger is disabled (GH-7285)
A check has been added in Logger.isEnabledFor() to return False when the logger is disabled. This avoids unnecessary work being done when a disabled logger is used.
This commit is contained in:
parent
9e24930dfd
commit
6e3ca645e7
2 changed files with 15 additions and 0 deletions
|
@ -4097,6 +4097,18 @@ class LoggerTest(BaseTest):
|
|||
self.addCleanup(setattr, self.logger.manager, 'disable', old_disable)
|
||||
self.assertFalse(self.logger.isEnabledFor(22))
|
||||
|
||||
def test_is_enabled_for_disabled_logger(self):
|
||||
old_disabled = self.logger.disabled
|
||||
old_disable = self.logger.manager.disable
|
||||
|
||||
self.logger.disabled = True
|
||||
self.logger.manager.disable = 21
|
||||
|
||||
self.addCleanup(setattr, self.logger, 'disabled', old_disabled)
|
||||
self.addCleanup(setattr, self.logger.manager, 'disable', old_disable)
|
||||
|
||||
self.assertFalse(self.logger.isEnabledFor(22))
|
||||
|
||||
def test_root_logger_aliases(self):
|
||||
root = logging.getLogger()
|
||||
self.assertIs(root, logging.root)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue