summaryrefslogtreecommitdiffstats
path: root/Lib/logging/__init__.py
diff options
context:
space:
mode:
authorVinay Sajip <vinay_sajip@yahoo.co.uk>2010-02-25 23:13:06 (GMT)
committerVinay Sajip <vinay_sajip@yahoo.co.uk>2010-02-25 23:13:06 (GMT)
commitdb81c4c63a702be1ec6e298bbee70634df873e68 (patch)
treeb9e8ba2245f23e17ecde423f7ff5126aac1eb108 /Lib/logging/__init__.py
parent6e796a1361d5bb53a0b5acd39029c94fe2a8c6bf (diff)
downloadcpython-db81c4c63a702be1ec6e298bbee70634df873e68.zip
cpython-db81c4c63a702be1ec6e298bbee70634df873e68.tar.gz
cpython-db81c4c63a702be1ec6e298bbee70634df873e68.tar.bz2
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/trunk ........ r77967 | vinay.sajip | 2010-02-04 18:48:53 +0000 (Thu, 04 Feb 2010) | 1 line Logging: Implemented PEP 391. ........ r77969 | vinay.sajip | 2010-02-04 20:18:28 +0000 (Thu, 04 Feb 2010) | 1 line Removed spurious print statement. ........ r78033 | benjamin.peterson | 2010-02-06 22:08:15 +0000 (Sat, 06 Feb 2010) | 1 line make waiting for the server to start robust ........ r78055 | vinay.sajip | 2010-02-07 01:37:08 +0000 (Sun, 07 Feb 2010) | 1 line Issue #7868: logging: added loggerClass attribute to Manager. ........ r78081 | vinay.sajip | 2010-02-07 12:56:54 +0000 (Sun, 07 Feb 2010) | 1 line Issue #7869: logging: improved format-time diagnostics and removed some 1.5.2 support code. ........ r78085 | vinay.sajip | 2010-02-07 13:06:51 +0000 (Sun, 07 Feb 2010) | 1 line logging: Removed some more 1.5.2 support code. ........ r78108 | vinay.sajip | 2010-02-08 21:18:15 +0000 (Mon, 08 Feb 2010) | 1 line logging: gingerly re-enabling skipped tests after improving thread sync code in configurator. ........
Diffstat (limited to 'Lib/logging/__init__.py')
-rw-r--r--Lib/logging/__init__.py26
1 files changed, 20 insertions, 6 deletions
diff --git a/Lib/logging/__init__.py b/Lib/logging/__init__.py
index 7becfda..073213f 100644
--- a/Lib/logging/__init__.py
+++ b/Lib/logging/__init__.py
@@ -1,4 +1,4 @@
-# Copyright 2001-2009 by Vinay Sajip. All Rights Reserved.
+# Copyright 2001-2010 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,
@@ -46,8 +46,8 @@ except ImportError:
__author__ = "Vinay Sajip <vinay_sajip@red-dove.com>"
__status__ = "production"
-__version__ = "0.5.1.1"
-__date__ = "25 November 2009"
+__version__ = "0.5.1.2"
+__date__ = "07 February 2010"
#---------------------------------------------------------------------------
# Miscellaneous module data
@@ -767,7 +767,10 @@ class Handler(Filterer):
if raiseExceptions:
ei = sys.exc_info()
try:
- traceback.print_exception(ei[0], ei[1], ei[2], None, sys.stderr)
+ traceback.print_exception(ei[0], ei[1], ei[2],
+ None, sys.stderr)
+ sys.stderr.write('Logged from file %s, line %s\n' % (
+ record.filename, record.lineno))
except IOError:
pass # see issue 5971
finally:
@@ -960,6 +963,7 @@ class Manager(object):
self.disable = 0
self.emittedNoHandlerWarning = 0
self.loggerDict = {}
+ self.loggerClass = None
def getLogger(self, name):
"""
@@ -979,13 +983,13 @@ class Manager(object):
rv = self.loggerDict[name]
if isinstance(rv, PlaceHolder):
ph = rv
- rv = _loggerClass(name)
+ rv = (self.loggerClass or _loggerClass)(name)
rv.manager = self
self.loggerDict[name] = rv
self._fixupChildren(ph, rv)
self._fixupParents(rv)
else:
- rv = _loggerClass(name)
+ rv = (self.loggerClass or _loggerClass)(name)
rv.manager = self
self.loggerDict[name] = rv
self._fixupParents(rv)
@@ -993,6 +997,16 @@ class Manager(object):
_releaseLock()
return rv
+ def setLoggerClass(self, klass):
+ """
+ Set the class to be used when instantiating a logger with this Manager.
+ """
+ if klass != Logger:
+ if not issubclass(klass, Logger):
+ raise TypeError("logger not derived from logging.Logger: "
+ + klass.__name__)
+ self.loggerClass = klass
+
def _fixupParents(self, alogger):
"""
Ensure that there are either loggers or placeholders all the way