Logging#

Module-Level Logger#

A convention is to use a module-level logger as follows:

import logging
_logger = logging.getLogger(__name__)

Log variable Data#

Logging uses the old “%-style” of string formatting. Also see:

Example:

_logger.warning("%s before you %s', 'Look', 'leap!")

Root Logger Configuration#

The easiest way to configure the root logger works like this:

import logging
logging.basicConfig(format="%(levelname)s:%(message)s", level=logging.DEBUG)

Change Logger Level#

Example:

logging.getLogger("module").setLevel(logging.DEBUG)