diff --git a/Lib/logging/config.py b/Lib/logging/config.py index 86a1e4eaf4cbc93bf1248b0d4f0596c52421ddcf..f9ef7b53a3d6488d3d90a2a1257afe5e69fb07c0 100644 --- a/Lib/logging/config.py +++ b/Lib/logging/config.py @@ -795,6 +795,7 @@ def configure_logger(self, name, config, incremental=False): """Configure a non-root logger from a dictionary.""" logger = logging.getLogger(name) self.common_logger_config(logger, config, incremental) + logger.disabled = False propagate = config.get('propagate', None) if propagate is not None: logger.propagate = propagate diff --git a/Lib/test/test_logging.py b/Lib/test/test_logging.py index 5349874c63c5250dc3b7850ede0c88d0e2e37b8b..350f4a57e2bbeea8550eeca397ba92f50a32c984 100644 --- a/Lib/test/test_logging.py +++ b/Lib/test/test_logging.py @@ -1,4 +1,4 @@ -# Copyright 2001-2021 by Vinay Sajip. All Rights Reserved. +# Copyright 2001-2022 by Vinay Sajip. All Rights Reserved. # # Permission to use, copy, modify, and distribute this software and its # documentation for any purpose and without fee is hereby granted, @@ -16,7 +16,7 @@ """Test harness for the logging module. Run all tests. -Copyright (C) 2001-2021 Vinay Sajip. All Rights Reserved. +Copyright (C) 2001-2022 Vinay Sajip. All Rights Reserved. """ import logging @@ -3504,6 +3504,35 @@ class NotAFilter: pass {"version": 1, "root": {"level": "DEBUG", "filters": [filter_]}} ) + 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): def test_manager_loggerclass(self):