There is actually one better thing: use the code logging.getLogger().isEnabledFor(logging.DEBUG) . I found this while trying to figure out what to do with the result of getEffectiveLevel() .
Below is the code that uses the registration module itself.
def getEffectiveLevel(self): """ Get the effective level for this logger. Loop through this logger and its parents in the blogger hierarchy, looking for a non-zero logging level. Return the first one found. """ logger = self while logger: if logger.level: return logger.level logger = logger.parent return NOTSET def isEnabledFor(self, level): """ Is this logger enabled for level 'level? """ if self.manager.disable >= level: return 0 return level >= self.getEffectiveLevel()
Pat Jan 08 '15 at 21:29 2015-01-08 21:29
source share