Skip to content

Logging

log

Utility functions for logging.

Classes

LoggingLevel

Bases: str, Enum

Logging level.

Attributes
NOTSET class-attribute instance-attribute
NOTSET = 'NOTSET'

When set on a logger, indicates that ancestor loggers are to be consulted to determine the effective level. If that still resolves to NOTSET, then all events are logged. When set on a handler, all events are handled.

DEBUG class-attribute instance-attribute
DEBUG = 'DEBUG'

Detailed information, typically only of interest to a developer trying to diagnose a problem.

INFO class-attribute instance-attribute
INFO = 'INFO'

Confirmation that things are working as expected.

WARNING class-attribute instance-attribute
WARNING = 'WARNING'

An indication that something unexpected happened, or that a problem might occur in the near future (e.g. 'disk space low'). The software is still working as expected.

ERROR class-attribute instance-attribute
ERROR = 'ERROR'

Due to a more serious problem, the software has not been able to perform some function.

CRITICAL class-attribute instance-attribute
CRITICAL = 'CRITICAL'

A serious error, indicating that the program itself may be unable to continue running.

Functions

get_version_information

get_version_information() -> str

Get the version information.

Returns:

Name Type Description
str str

Version information.

setup_logger

setup_logger(outdir: str = '.', filename: str | None = None, log_level: LoggingLevel | str | int = 'INFO', print_version: bool = False) -> None

Set up logging output: call at the start of the script to use.

Parameters:

Name Type Description Default
outdir str

Output directory for log file.

'.'
filename str | None

Name of the log file. If None, no log file is created.

None
log_level LoggingLevel | str | int

Logging level as string or integer.

'INFO'
print_version bool

Whether to print version information to the log.

False