[issue8162] logging.disable() incoherency

Pascal Chambon report at bugs.python.org
Wed Mar 17 11:06:36 CET 2010

New submission from Pascal Chambon <chambon.pascal at gmail.com>:


I see some trouble in the semantic of logging.disable(lvl) :
according to the doc (and docstrings), it's the same as a logger.setLevel(lvl) called on all logger, but in reality it doesn't act the same way : when we call logger.setLevel(lvl), log messages at level lvl WILL be logged, whereas with logger.disable(lvl), they will NOT be logged (CF method below from logging/__init__.py).

So maybe the best would be to explain that disable() also disable the target level itself, and to set by default this disabling level to -1 (and not 0 as currently), so that by default ALL messages get loged, even those set to level 0.

    def isEnabledFor(self, level):
        Is this logger enabled for level 'level'?
        if self.manager.disable >= level:
            return 0
        return level >= self.getEffectiveLevel()

assignee: georg.brandl
components: Documentation, Library (Lib)
messages: 101215
nosy: georg.brandl, pakal
severity: normal
status: open
title: logging.disable() incoherency
type: behavior
versions: Python 2.6, Python 2.7

Python tracker <report at bugs.python.org>

More information about the Python-bugs-list mailing list