There is no need for additional checks. Just configure your logging level:
>>> import logging
>>> root = logging.getLogger()
>>> root.setLevel(logging.INFO)
>>> root.addHandler(logging.StreamHandler())
>>> logging.error("test")
test
>>> logging.debug("test")
>>>
Again, there is no need for additional checks (the source code taken from logging/__init__.py
):
class Logger(Filterer):
...
def debug(self, msg, *args, **kwargs):
"""
Log 'msg % args' with severity 'DEBUG'.
To pass exception information, use the keyword argument exc_info with
a true value, e.g.
logger.debug("Houston, we have a %s", "thorny problem", exc_info=1)
"""
if self.isEnabledFor(DEBUG):
self._log(DEBUG, msg, args, **kwargs)
As you can see logging itself makes the check.
Hope that helps.