summaryrefslogtreecommitdiffstats
path: root/Lib/logging
diff options
context:
space:
mode:
authorChristian Heimes <christian@cheimes.de>2007-11-12 01:32:03 (GMT)
committerChristian Heimes <christian@cheimes.de>2007-11-12 01:32:03 (GMT)
commit96f31636f4af949dd0975c9381d284915c9d76f6 (patch)
tree61de113ffa9a0011ca4280a208f825dc726b4438 /Lib/logging
parent29fd7120e420014d5c32f5864a1d3c19ffa73c7f (diff)
downloadcpython-96f31636f4af949dd0975c9381d284915c9d76f6.zip
cpython-96f31636f4af949dd0975c9381d284915c9d76f6.tar.gz
cpython-96f31636f4af949dd0975c9381d284915c9d76f6.tar.bz2
Merged revisions 58930-58938 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r58931 | vinay.sajip | 2007-11-11 15:27:30 +0100 (Sun, 11 Nov 2007) | 1 line Fixed a bug reported (in private email, by Robert Crida) in logging configuration whereby child loggers of a logger named in a configuration file, which are not themselves named in the configuration, are disabled when the configuration is applied. ........ r58932 | georg.brandl | 2007-11-11 16:16:16 +0100 (Sun, 11 Nov 2007) | 2 lines Remove duplication of "this". ........ r58935 | christian.heimes | 2007-11-12 02:15:40 +0100 (Mon, 12 Nov 2007) | 2 lines Added new decorator syntax to property.__doc__ Guido prefers _x over __x. ........ r58936 | christian.heimes | 2007-11-12 02:20:56 +0100 (Mon, 12 Nov 2007) | 2 lines Fix for #1427: Error in standard module calendar the prweek() method is still broken and I can't figure out how it suppose to work. ........ r58938 | andrew.kuchling | 2007-11-12 02:25:21 +0100 (Mon, 12 Nov 2007) | 1 line Re-word sentence ........
Diffstat (limited to 'Lib/logging')
-rw-r--r--Lib/logging/config.py30
1 files changed, 27 insertions, 3 deletions
diff --git a/Lib/logging/config.py b/Lib/logging/config.py
index ed14052..e5b8bb1 100644
--- a/Lib/logging/config.py
+++ b/Lib/logging/config.py
@@ -1,4 +1,4 @@
-# Copyright 2001-2005 by Vinay Sajip. All Rights Reserved.
+# Copyright 2001-2007 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,
@@ -22,7 +22,7 @@ by Apache's log4j system.
Should work under Python versions >= 1.5.2, except that source line
information is not available unless 'sys._getframe()' is.
-Copyright (C) 2001-2004 Vinay Sajip. All Rights Reserved.
+Copyright (C) 2001-2007 Vinay Sajip. All Rights Reserved.
To use, simply 'import logging' and log away!
"""
@@ -203,6 +203,14 @@ def _install_loggers(cp, handlers):
#which were in the previous configuration but
#which are not in the new configuration.
existing = list(root.manager.loggerDict.keys())
+ #The list needs to be sorted so that we can
+ #avoid disabling child loggers of explicitly
+ #named loggers. With a sorted list it is easier
+ #to find the child loggers.
+ existing.sort()
+ #We'll keep the list of existing loggers
+ #which are children of named loggers here...
+ child_loggers = []
#now set up the new ones...
for log in llist:
sectname = "logger_%s" % log
@@ -214,6 +222,14 @@ def _install_loggers(cp, handlers):
propagate = 1
logger = logging.getLogger(qn)
if qn in existing:
+ i = existing.index(qn)
+ prefixed = qn + "."
+ pflen = len(prefixed)
+ num_existing = len(existing)
+ i = i + 1 # look at the entry after qn
+ while (i < num_existing) and (existing[i][:pflen] == prefixed):
+ child_loggers.append(existing[i])
+ i = i + 1
existing.remove(qn)
if "level" in opts:
level = cp.get(sectname, "level")
@@ -231,8 +247,16 @@ def _install_loggers(cp, handlers):
#Disable any old loggers. There's no point deleting
#them as other threads may continue to hold references
#and by disabling them, you stop them doing any logging.
+ #However, don't disable children of named loggers, as that's
+ #probably not what was intended by the user.
for log in existing:
- root.manager.loggerDict[log].disabled = 1
+ logger = root.manager.loggerDict[log]
+ if log in child_loggers:
+ logger.level = logging.NOTSET
+ logger.handlers = []
+ logger.propagate = 1
+ else:
+ logger.disabled = 1
def listen(port=DEFAULT_LOGGING_CONFIG_PORT):