Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit db81c4c

Browse files
committed
Merged revisions 77967,77969,78033,78055,78081,78085,78108 via svnmerge from
svn+ssh://[email protected]/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. ........
1 parent 6e796a1 commit db81c4c

5 files changed

Lines changed: 1286 additions & 75 deletions

File tree

Lib/logging/__init__.py

Lines changed: 20 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# Copyright 2001-2009 by Vinay Sajip. All Rights Reserved.
1+
# Copyright 2001-2010 by Vinay Sajip. All Rights Reserved.
22
#
33
# Permission to use, copy, modify, and distribute this software and its
44
# documentation for any purpose and without fee is hereby granted,
@@ -46,8 +46,8 @@
4646

4747
__author__ = "Vinay Sajip <[email protected]>"
4848
__status__ = "production"
49-
__version__ = "0.5.1.1"
50-
__date__ = "25 November 2009"
49+
__version__ = "0.5.1.2"
50+
__date__ = "07 February 2010"
5151

5252
#---------------------------------------------------------------------------
5353
# Miscellaneous module data
@@ -767,7 +767,10 @@ def handleError(self, record):
767767
if raiseExceptions:
768768
ei = sys.exc_info()
769769
try:
770-
traceback.print_exception(ei[0], ei[1], ei[2], None, sys.stderr)
770+
traceback.print_exception(ei[0], ei[1], ei[2],
771+
None, sys.stderr)
772+
sys.stderr.write('Logged from file %s, line %s\n' % (
773+
record.filename, record.lineno))
771774
except IOError:
772775
pass # see issue 5971
773776
finally:
@@ -960,6 +963,7 @@ def __init__(self, rootnode):
960963
self.disable = 0
961964
self.emittedNoHandlerWarning = 0
962965
self.loggerDict = {}
966+
self.loggerClass = None
963967

964968
def getLogger(self, name):
965969
"""
@@ -979,20 +983,30 @@ def getLogger(self, name):
979983
rv = self.loggerDict[name]
980984
if isinstance(rv, PlaceHolder):
981985
ph = rv
982-
rv = _loggerClass(name)
986+
rv = (self.loggerClass or _loggerClass)(name)
983987
rv.manager = self
984988
self.loggerDict[name] = rv
985989
self._fixupChildren(ph, rv)
986990
self._fixupParents(rv)
987991
else:
988-
rv = _loggerClass(name)
992+
rv = (self.loggerClass or _loggerClass)(name)
989993
rv.manager = self
990994
self.loggerDict[name] = rv
991995
self._fixupParents(rv)
992996
finally:
993997
_releaseLock()
994998
return rv
995999

1000+
def setLoggerClass(self, klass):
1001+
"""
1002+
Set the class to be used when instantiating a logger with this Manager.
1003+
"""
1004+
if klass != Logger:
1005+
if not issubclass(klass, Logger):
1006+
raise TypeError("logger not derived from logging.Logger: "
1007+
+ klass.__name__)
1008+
self.loggerClass = klass
1009+
9961010
def _fixupParents(self, alogger):
9971011
"""
9981012
Ensure that there are either loggers or placeholders all the way

0 commit comments

Comments
 (0)