[issue6314] logging.basicConfig(level='DEBUG', ... and setLevel("DEBUG") result in no logging

Vinay Sajip report at bugs.python.org
Tue Jul 7 09:10:01 CEST 2009


Vinay Sajip <vinay_sajip at yahoo.co.uk> added the comment:

The change that I made was in the wrong place - it should have been in
the setLevel rather than in basicConfig itself. However, this would not
have covered setLevel for Handlers...

That setLevel behaves differently to basicConfig for the level argument
could be seen as a bug. ISTM I should add a function _checkLevel as follows:

def _checkLevel(level):
    if isinstance(level, int):
        rv = level
    elif str(level) == level:
        if level not in _levelNames:
            raise ValueError("Unknown level: %r" % level)
        rv = _levelNames[level]
    else:
        raise TypeError("Level not an integer or a valid string: %r" %
level)
    return rv


and then have all setLevel(level) methods do a "level =
_checkLevel(level)" before actually setting the level.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue6314>
_______________________________________


More information about the Python-bugs-list mailing list