Closes #17521: Merged fix from 3.3.
This commit is contained in:
commit
8ec95b81d5
@ -175,8 +175,8 @@ def _handle_existing_loggers(existing, child_loggers, disable_existing):
|
|||||||
logger.level = logging.NOTSET
|
logger.level = logging.NOTSET
|
||||||
logger.handlers = []
|
logger.handlers = []
|
||||||
logger.propagate = True
|
logger.propagate = True
|
||||||
elif disable_existing:
|
else:
|
||||||
logger.disabled = True
|
logger.disabled = disable_existing
|
||||||
|
|
||||||
def _install_loggers(cp, handlers, disable_existing):
|
def _install_loggers(cp, handlers, disable_existing):
|
||||||
"""Create and install loggers"""
|
"""Create and install loggers"""
|
||||||
|
@ -1261,9 +1261,30 @@ class ConfigFileTest(BaseTest):
|
|||||||
datefmt=
|
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))
|
file = io.StringIO(textwrap.dedent(conf))
|
||||||
logging.config.fileConfig(file)
|
logging.config.fileConfig(file, **kwargs)
|
||||||
|
|
||||||
def test_config0_ok(self):
|
def test_config0_ok(self):
|
||||||
# A simple config file which overrides the default settings.
|
# A simple config file which overrides the default settings.
|
||||||
@ -1385,6 +1406,15 @@ class ConfigFileTest(BaseTest):
|
|||||||
# Original logger output is empty.
|
# Original logger output is empty.
|
||||||
self.assert_log_lines([])
|
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)
|
||||||
|
|
||||||
|
|
||||||
@unittest.skipUnless(threading, 'Threading required for this test.')
|
@unittest.skipUnless(threading, 'Threading required for this test.')
|
||||||
class SocketHandlerTest(BaseTest):
|
class SocketHandlerTest(BaseTest):
|
||||||
|
@ -294,6 +294,9 @@ Core and Builtins
|
|||||||
Library
|
Library
|
||||||
-------
|
-------
|
||||||
|
|
||||||
|
- Issue #17521: Corrected non-enabling of logger following two calls to
|
||||||
|
fileConfig().
|
||||||
|
|
||||||
- Issue #17508: Corrected MemoryHandler configuration in dictConfig() where
|
- Issue #17508: Corrected MemoryHandler configuration in dictConfig() where
|
||||||
the target handler wasn't configured first.
|
the target handler wasn't configured first.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user