class documentation

This class handles enhanced console and rotating file in loguru logging.

The following functionality is implemented:
  • thread and multiprocessing safe.
  • Rotating log files are based on date.
  • Console output is colored based on log level.
Method __init__ Add console and rotating log file handler into Loguru logging.
Method start Set initial log level filter.
Method update_loglevel Update logging level filter.
Instance Variable log_filter DynamicLogFilter object.
def __init__(self, log_path: Path, program: str, lean_format: bool = True, include_external: bool = False, supress_console: bool = False): (source)

Add console and rotating log file handler into Loguru logging.

Setting supress_console=True is used when building a Windows service or when a Linux program is managed by systemctl.

Parameters
log_path:PathLogfile path.
program:strName of logging program.
lean_format:boolUse a lean log format; when you set it to False, the standard loguru format is used (default is True).
include_external:boolInclude python standard logging into Loguru (default is False).
supress_console:boolSuppress console logging (default is False).
def start(self, log_level: str, suppress: bool = False): (source)

Set initial log level filter.

Possible log_level values are:
  • trace,
  • debug,
  • info,
  • success,
  • warning,
  • error,
  • critical.
Parameters
log_level:strName of log level.
suppress:boolSuppress an initial log message (default id False).
def update_loglevel(self, log_level: str): (source)

Update logging level filter.

Possible log_level values are:
  • trace,
  • debug,
  • info,
  • success,
  • warning,
  • error,
  • critical.
Parameters
log_level:strName of applied log level.

DynamicLogFilter object.