[ python-Bugs-1284928 ] logging module's setLoggerClass not really working

SourceForge.net noreply at sourceforge.net
Mon Sep 19 08:34:53 CEST 2005


Bugs item #1284928, was opened at 2005-09-08 16:51
Message generated for change (Comment added) made by rotem_ya
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1284928&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Rotem Yaari (rotem_ya)
Assigned to: Nobody/Anonymous (nobody)
Summary: logging module's setLoggerClass not really working

Initial Comment:
The logging package should be modified in a way which
would let users call the setLoggerClass API, and then
consistently get loggers only from that class. 

In the logging package as it is today, the root logger
will always be a logging.Logger instance, and not the
new class specified in the call to setLoggerClass.
These semantics are not clear.

----------------------------------------------------------------------

>Comment By: Rotem Yaari (rotem_ya)
Date: 2005-09-19 09:34

Message:
Logged In: YES 
user_id=1340892

This is an example logger class I would like to use:

class PatchedLogger(logging.Logger):
    def __init__(self, name, *patches):
        logging.Logger.__init__(self, name)
        self.patches = patches
    def handle(self, record):
        #copied from the actual Logger implementation
        if (not self.disabled) and self.filter(record):
            for patch in self.patches:
                patch(record)
            self.callHandlers(record)

And an example "patch":
def EnableTrace(record):
    """
    adds the %(function)s for logging records
    """
    function_name = _get_function_name(inspect.stack()[4])
    record.function = function_name


----------------------------------------------------------------------

Comment By: Vinay Sajip (vsajip)
Date: 2005-09-19 04:00

Message:
Logged In: YES 
user_id=308438

Can you please explain your use case? Why does the package
have to be modified in that way? Why do you need to be able
to have the root logger be creatable from a custom class?

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1284928&group_id=5470


More information about the Python-bugs-list mailing list