mirror of
https://github.com/python/cpython.git
synced 2025-08-30 05:35:08 +00:00
Issue #17521: Corrected non-enabling of logger following two calls to fileConfig().
This commit is contained in:
parent
a4cfd60f3d
commit
68b4cc87cd
3 changed files with 37 additions and 4 deletions
|
@ -764,9 +764,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 = io.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.
|
||||
|
@ -870,6 +891,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
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue