]> granicus.if.org Git - python/commitdiff
Bug #3136: fileConfig()'s disabling of old loggers is now conditional via an optional...
authorVinay Sajip <vinay_sajip@yahoo.co.uk>
Thu, 19 Jun 2008 22:40:17 +0000 (22:40 +0000)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>
Thu, 19 Jun 2008 22:40:17 +0000 (22:40 +0000)
Thanks to Leandro Lucarella for the patch.

Lib/logging/config.py

index c95842c7d9994bc5f2ce12d4ce17b2936b80c0bf..822b283623f44ceff3f4442c80849667dd89e978 100644 (file)
@@ -52,7 +52,7 @@ else:
 #   _listener holds the server object doing the listening
 _listener = None
 
-def fileConfig(fname, defaults=None):
+def fileConfig(fname, defaults=None, disable_existing_loggers=1):
     """
     Read the logging configuration from a ConfigParser-format file.
 
@@ -82,7 +82,7 @@ def fileConfig(fname, defaults=None):
         del logging._handlerList[:]
         # Handlers add themselves to logging._handlers
         handlers = _install_handlers(cp, formatters)
-        _install_loggers(cp, handlers)
+        _install_loggers(cp, handlers, disable_existing_loggers)
     finally:
         logging._releaseLock()
 
@@ -170,7 +170,7 @@ def _install_handlers(cp, formatters):
     return handlers
 
 
-def _install_loggers(cp, handlers):
+def _install_loggers(cp, handlers, disable_existing_loggers):
     """Create and install loggers"""
 
     # configure the root first
@@ -255,7 +255,7 @@ def _install_loggers(cp, handlers):
             logger.level = logging.NOTSET
             logger.handlers = []
             logger.propagate = 1
-        else:
+        elif disable_existing_loggers:
             logger.disabled = 1