Added getLoggerClass()

This commit is contained in:
Vinay Sajip 2004-09-22 12:39:26 +00:00
parent a2fc7ec80a
commit b9591174df
1 changed files with 15 additions and 12 deletions

View File

@ -36,8 +36,8 @@ except ImportError:
__author__ = "Vinay Sajip <vinay_sajip@red-dove.com>" __author__ = "Vinay Sajip <vinay_sajip@red-dove.com>"
__status__ = "beta" __status__ = "beta"
__version__ = "0.4.9.3" __version__ = "0.4.9.4"
__date__ = "08 July 2004" __date__ = "22 September 2004"
#--------------------------------------------------------------------------- #---------------------------------------------------------------------------
# Miscellaneous module data # Miscellaneous module data
@ -689,13 +689,14 @@ class StreamHandler(Handler):
""" """
try: try:
msg = self.format(record) msg = self.format(record)
fs = "%s\n"
if not hasattr(types, "UnicodeType"): #if no unicode support... if not hasattr(types, "UnicodeType"): #if no unicode support...
self.stream.write("%s\n" % msg) self.stream.write(fs % msg)
else: else:
try: try:
self.stream.write("%s\n" % msg) self.stream.write(fs % msg)
except UnicodeError: except UnicodeError:
self.stream.write("%s\n" % msg.encode("UTF-8")) self.stream.write(fs % msg.encode("UTF-8"))
self.flush() self.flush()
except: except:
self.handleError(record) self.handleError(record)
@ -763,6 +764,13 @@ def setLoggerClass(klass):
global _loggerClass global _loggerClass
_loggerClass = klass _loggerClass = klass
def getLoggerClass():
"""
Return the class to be used when instantiating a logger.
"""
return _loggerClass
class Manager: class Manager:
""" """
There is [under normal circumstances] just one Manager instance, which There is [under normal circumstances] just one Manager instance, which
@ -780,7 +788,8 @@ class Manager:
def getLogger(self, name): def getLogger(self, name):
""" """
Get a logger with the specified name (channel name), creating it Get a logger with the specified name (channel name), creating it
if it doesn't yet exist. if it doesn't yet exist. This name is a dot-separated hierarchical
name, such as "a", "a.b", "a.b.c" or similar.
If a PlaceHolder existed for the specified name [i.e. the logger If a PlaceHolder existed for the specified name [i.e. the logger
didn't exist but a child of it did], replace it with the created didn't exist but a child of it did], replace it with the created
@ -879,12 +888,6 @@ class Logger(Filterer):
""" """
self.level = level self.level = level
# def getRoot(self):
# """
# Get the root of the logger hierarchy.
# """
# return Logger.root
def debug(self, msg, *args, **kwargs): def debug(self, msg, *args, **kwargs):
""" """
Log 'msg % args' with severity 'DEBUG'. Log 'msg % args' with severity 'DEBUG'.