[Python-checkins] cpython (2.7): Issue #17521: Corrected non-enabling of logger following two calls to
vinay.sajip
python-checkins at python.org
Sat Mar 23 12:23:28 CET 2013
http://hg.python.org/cpython/rev/533b4a1d2b23
changeset: 82896:533b4a1d2b23
branch: 2.7
parent: 82891:5f6747a0ffc4
user: Vinay Sajip <vinay_sajip at yahoo.co.uk>
date: Sat Mar 23 11:18:10 2013 +0000
summary:
Issue #17521: Corrected non-enabling of logger following two calls to fileConfig().
files:
Lib/logging/config.py | 4 +-
Lib/test/test_logging.py | 34 ++++++++++++++++++++++++++-
Misc/NEWS | 3 ++
3 files changed, 37 insertions(+), 4 deletions(-)
diff --git a/Lib/logging/config.py b/Lib/logging/config.py
--- a/Lib/logging/config.py
+++ b/Lib/logging/config.py
@@ -260,8 +260,8 @@
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
--- a/Lib/test/test_logging.py
+++ b/Lib/test/test_logging.py
@@ -714,9 +714,30 @@
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 @@
# 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
diff --git a/Misc/NEWS b/Misc/NEWS
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -216,6 +216,9 @@
Library
-------
+- Issue #17521: Corrected non-enabling of logger following two calls to
+ fileConfig().
+
- Issue #17508: Corrected MemoryHandler configuration in dictConfig() where
the target handler wasn't configured first.
--
Repository URL: http://hg.python.org/cpython
More information about the Python-checkins
mailing list