Bugs item #1008295, was opened at 2004-08-12 21:56
Message generated for change (Comment added) made by vsajip
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1008295&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: Python 2.3
Status: Closed
Resolution: Fixed
Priority: 5
Submitted By: Paulo Eduardo Neves (neves)
Assigned to: Vinay Sajip (vsajip)
Summary: logging.getLevelName returns a number

Initial Comment:
logging.getLevelName function doc says that it returns
the "textual representation of logging level", but if
the argument is already the level name, the log level
integer is returned. It should return the argument.

The problem is that if I add my own levels, and call
LoggerInstance.log( levelName, message ), the formatter
will save the level number in the log, insted of the
desired level name. 

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

>Comment By: Vinay Sajip (vsajip)
Date: 2006-09-20 13:47

Message:
Logged In: YES 
user_id=308438

Yes, that's the way it's supposed to work - the map works
both ways, allowing the mapping of names to levels as well
as levels to names. This is because both types of mapping
are needed in the package, and it makes sense to reuse the 
dictionary rather than have two separate dictionaries.

In your example, you are calling setLevel with a string
argument [newLoglevel.upper ()], which is incorrect.

I will clarify the setLevel() documentation to point out
that the level passed to setLevel() is an integer.

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

Comment By: Steve Pole (stevepole)
Date: 2006-09-20 04:06

Message:
Logged In: YES 
user_id=455201

I understand this is not a bug, it's by design.

It still looks like a bug, though. Please consider the
following code:

import logging

defaultLoglevel = logging.DEBUG
newLoglevel     = 'WARNING'

logging.basicConfig (level = defaultLoglevel, format =
'%(message)s')
print logging.getLevelName (logging.getLogger
().getEffectiveLevel ())
print logging.getLogger ().getEffectiveLevel ()
logging.getLogger ().setLevel (newLoglevel.upper ())
print logging.getLevelName (logging.getLogger
().getEffectiveLevel ())
print logging.getLogger ().getEffectiveLevel ()

Output:
DEBUG
10
30
WARNING

So the result basically inverts. Is that really the way it
is supposed to work ?

Or am I misunderstanding something ?


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

Comment By: Vinay Sajip (vsajip)
Date: 2004-08-20 12:36

Message:
Logged In: YES 
user_id=308438

This is not a bug, it's by design. Current CVS throws an
exception if raiseExceptions is set and you pass anything
other than an integer as the log level. The CVS
documentation has also been updated to clarify that the
level passed in is the integer rather than the level name.

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

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1008295&group_id=5470
_______________________________________________
Python-bugs-list mailing list 
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to