diff options
author | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2013-03-23 11:18:10 (GMT) |
---|---|---|
committer | Vinay Sajip <vinay_sajip@yahoo.co.uk> | 2013-03-23 11:18:10 (GMT) |
commit | bb2dad8915a864503e3f81657f41500f0a49d987 (patch) | |
tree | 8a8448f1f7ff18d8a65d0f5bc866b0766d621e38 /Lib | |
parent | 0e29f22855a1ed92b12e5bf700af19ddf34c21c8 (diff) | |
download | cpython-bb2dad8915a864503e3f81657f41500f0a49d987.zip cpython-bb2dad8915a864503e3f81657f41500f0a49d987.tar.gz cpython-bb2dad8915a864503e3f81657f41500f0a49d987.tar.bz2 |
Issue #17521: Corrected non-enabling of logger following two calls to fileConfig().
Diffstat (limited to 'Lib')
-rw-r--r-- | Lib/logging/config.py | 4 | ||||
-rw-r--r-- | Lib/test/test_logging.py | 34 |
2 files changed, 34 insertions, 4 deletions
diff --git a/Lib/logging/config.py b/Lib/logging/config.py index e3c9324..37729d8 100644 --- a/Lib/logging/config.py +++ b/Lib/logging/config.py @@ -260,8 +260,8 @@ def _install_loggers(cp, handlers, disable_existing_loggers): logger.level = logging.NOTSET logger.handlers = [] logger.propagate = 1 - elif disable_existing_loggers: - logger.disabled = 1 + else: + logger.disabled = disable_existing_loggers diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py index a8c4450..31bc48e 100644 --- a/Lib/test/test_logging.py +++ b/Lib/test/test_logging.py @@ -714,9 +714,30 @@ class ConfigFileTest(BaseTest): datefmt= """ - def apply_config(self, conf): + disable_test = """ + [loggers] + keys=root + + [handlers] + keys=screen + + [formatters] + keys= + + [logger_root] + level=DEBUG + handlers=screen + + [handler_screen] + level=DEBUG + class=StreamHandler + args=(sys.stdout,) + formatter= + """ + + def apply_config(self, conf, **kwargs): file = cStringIO.StringIO(textwrap.dedent(conf)) - logging.config.fileConfig(file) + logging.config.fileConfig(file, **kwargs) def test_config0_ok(self): # A simple config file which overrides the default settings. @@ -820,6 +841,15 @@ class ConfigFileTest(BaseTest): # Original logger output is empty. self.assert_log_lines([]) + def test_logger_disabling(self): + self.apply_config(self.disable_test) + logger = logging.getLogger('foo') + self.assertFalse(logger.disabled) + self.apply_config(self.disable_test) + self.assertTrue(logger.disabled) + self.apply_config(self.disable_test, disable_existing_loggers=False) + self.assertFalse(logger.disabled) + class LogRecordStreamHandler(StreamRequestHandler): """Handler for a streaming logging request. It saves the log message in the |