mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
gh-90195: Unset logger disabled flag when configuring it. (GH-96530)
This commit is contained in:
parent
e5823bf9b5
commit
ac4ddab405
2 changed files with 30 additions and 0 deletions
|
@ -869,6 +869,7 @@ class DictConfigurator(BaseConfigurator):
|
||||||
"""Configure a non-root logger from a dictionary."""
|
"""Configure a non-root logger from a dictionary."""
|
||||||
logger = logging.getLogger(name)
|
logger = logging.getLogger(name)
|
||||||
self.common_logger_config(logger, config, incremental)
|
self.common_logger_config(logger, config, incremental)
|
||||||
|
logger.disabled = False
|
||||||
propagate = config.get('propagate', None)
|
propagate = config.get('propagate', None)
|
||||||
if propagate is not None:
|
if propagate is not None:
|
||||||
logger.propagate = propagate
|
logger.propagate = propagate
|
||||||
|
|
|
@ -3677,6 +3677,35 @@ class ConfigDictTest(BaseTest):
|
||||||
msg = str(ctx.exception)
|
msg = str(ctx.exception)
|
||||||
self.assertEqual(msg, "Unable to configure handler 'ah'")
|
self.assertEqual(msg, "Unable to configure handler 'ah'")
|
||||||
|
|
||||||
|
def test_90195(self):
|
||||||
|
# See gh-90195
|
||||||
|
config = {
|
||||||
|
'version': 1,
|
||||||
|
'disable_existing_loggers': False,
|
||||||
|
'handlers': {
|
||||||
|
'console': {
|
||||||
|
'level': 'DEBUG',
|
||||||
|
'class': 'logging.StreamHandler',
|
||||||
|
},
|
||||||
|
},
|
||||||
|
'loggers': {
|
||||||
|
'a': {
|
||||||
|
'level': 'DEBUG',
|
||||||
|
'handlers': ['console']
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
logger = logging.getLogger('a')
|
||||||
|
self.assertFalse(logger.disabled)
|
||||||
|
self.apply_config(config)
|
||||||
|
self.assertFalse(logger.disabled)
|
||||||
|
# Should disable all loggers ...
|
||||||
|
self.apply_config({'version': 1})
|
||||||
|
self.assertTrue(logger.disabled)
|
||||||
|
del config['disable_existing_loggers']
|
||||||
|
self.apply_config(config)
|
||||||
|
# Logger should be enabled, since explicitly mentioned
|
||||||
|
self.assertFalse(logger.disabled)
|
||||||
|
|
||||||
class ManagerTest(BaseTest):
|
class ManagerTest(BaseTest):
|
||||||
def test_manager_loggerclass(self):
|
def test_manager_loggerclass(self):
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue