[ python-Bugs-876421 ] logging handlers raise exception on level

SourceForge.net noreply at sourceforge.net
Mon Jan 19 12:57:07 EST 2004


Bugs item #876421, was opened at 2004-01-13 17:04
Message generated for change (Comment added) made by jimjjewett
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=876421&group_id=5470

Category: Python Library
Group: Python 2.3
Status: Closed
Resolution: Invalid
Priority: 5
Submitted By: Jim Jewett (jimjjewett)
Assigned to: Vinay Sajip (vsajip)
Summary: logging handlers raise exception on level

Initial Comment:
logging.__version__ = "0.4.8.1" - matches CVS

Handler() takes a keyword argument of level, for the 
initial level of message it should care about.

StreamHandler inherits from Handler, but does not pass 
the level keyword through when calling Handler__init__.

    #def __init__(self, strm=None):
    def __init__(self, strm=None, **kwargs):

         #Handler.__init__(self)
         # should we delete the key that Stream uses?
         Handler.__init__(self, **kwargs)


I am submitting as a bug rather than a patch because 
several other classes have the same problem, and 
because I am not sure whether arguments used by the 
child initializer (such as strm) should be passed on.




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

>Comment By: Jim Jewett (jimjjewett)
Date: 2004-01-19 12:57

Message:
Logged In: YES 
user_id=764593

In general, it seems odd that Class(arg=val) would work, but 
subClass(arg=val) would fail, unless subclass is designed 
explicitly to restrict capabilities.  

logfile = logging.Handler(level=logging.ERROR) works.[1]  

logfile = logging.StreamHandler(level=logging.ERROR) fails, even 
though the level is still relevant and reasonable.

If I submit a patch for the classes distributed with the library, 
would it be an acceptable change?

[1] Admittedly, this handler might fail later, because Handler.
emit() assumes that Handler is abstract.


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

Comment By: Vinay Sajip (vsajip)
Date: 2004-01-18 14:02

Message:
Logged In: YES 
user_id=308438

I don't think this is a bug. You should consider that 
Handler.__init__() takes a level argument with a default 
value, rather than a keyword argument. This should be 
treated as an internal implementation detail, used only by 
subclasses of Handler. If you are writing a Handler subclass, 
you can pass the level argument via your 
HandlerSubclass.__init__() to Handler.__init__(). Otherwise, 
you can set the level using Handler.setLevel().

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

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



More information about the Python-bugs-list mailing list