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.getLogger().setLevel(logging.INFO)
logging.getLogger().addHandler(logging.StreamHandler())
Last modified January 1, 2023: add Module-Level Logger (12190a5)