diff options
| author | Timo Furrer <tuxtimo@gmail.com> | 2018-06-01 07:29:46 (GMT) |
|---|---|---|
| committer | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2018-06-01 07:29:46 (GMT) |
| commit | 6e3ca645e71dd021fead5a70dc06d9b663612e3a (patch) | |
| tree | b518e8e15dba48672a1624b5822aec6ffd25ac8a /Lib/test/test_logging.py | |
| parent | 9e24930dfdc28e16dabbfd7dd1ead1336b7b0d6c (diff) | |
| download | cpython-6e3ca645e71dd021fead5a70dc06d9b663612e3a.zip cpython-6e3ca645e71dd021fead5a70dc06d9b663612e3a.tar.gz cpython-6e3ca645e71dd021fead5a70dc06d9b663612e3a.tar.bz2 | |
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.
Diffstat (limited to 'Lib/test/test_logging.py')
| -rw-r--r-- | Lib/test/test_logging.py | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py index eee2ed0..e02bb31 100644 --- a/Lib/test/test_logging.py +++ b/Lib/test/test_logging.py @@ -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) |
