Skip to content

Commit ac4ddab

Browse files
authored
gh-90195: Unset logger disabled flag when configuring it. (GH-96530)
1 parent e5823bf commit ac4ddab

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-0
lines changed

Lib/logging/config.py

+1
Original file line numberDiff line numberDiff line change
@@ -869,6 +869,7 @@ def configure_logger(self, name, config, incremental=False):
869869
"""Configure a non-root logger from a dictionary."""
870870
logger = logging.getLogger(name)
871871
self.common_logger_config(logger, config, incremental)
872+
logger.disabled = False
872873
propagate = config.get('propagate', None)
873874
if propagate is not None:
874875
logger.propagate = propagate

Lib/test/test_logging.py

+29
Original file line numberDiff line numberDiff line change
@@ -3677,6 +3677,35 @@ def test_config_queue_handler(self):
36773677
msg = str(ctx.exception)
36783678
self.assertEqual(msg, "Unable to configure handler 'ah'")
36793679

3680+
def test_90195(self):
3681+
# See gh-90195
3682+
config = {
3683+
'version': 1,
3684+
'disable_existing_loggers': False,
3685+
'handlers': {
3686+
'console': {
3687+
'level': 'DEBUG',
3688+
'class': 'logging.StreamHandler',
3689+
},
3690+
},
3691+
'loggers': {
3692+
'a': {
3693+
'level': 'DEBUG',
3694+
'handlers': ['console']
3695+
}
3696+
}
3697+
}
3698+
logger = logging.getLogger('a')
3699+
self.assertFalse(logger.disabled)
3700+
self.apply_config(config)
3701+
self.assertFalse(logger.disabled)
3702+
# Should disable all loggers ...
3703+
self.apply_config({'version': 1})
3704+
self.assertTrue(logger.disabled)
3705+
del config['disable_existing_loggers']
3706+
self.apply_config(config)
3707+
# Logger should be enabled, since explicitly mentioned
3708+
self.assertFalse(logger.disabled)
36803709

36813710
class ManagerTest(BaseTest):
36823711
def test_manager_loggerclass(self):

0 commit comments

Comments
 (0)