logging

Helpers for TekHSI logging.

LoggingLevels

Bases: Enum

flowchart LR tekhsi.helpers.logging.LoggingLevels[LoggingLevels] click tekhsi.helpers.logging.LoggingLevels href "" "tekhsi.helpers.logging.LoggingLevels"

A class holding the valid logging levels supported.

CRITICAL class-attribute instance-attribute

CRITICAL = 'CRITICAL'

An enum member representing the CRITICAL logging level.

DEBUG class-attribute instance-attribute

DEBUG = 'DEBUG'

An enum member representing the DEBUG logging level.

ERROR class-attribute instance-attribute

ERROR = 'ERROR'

An enum member representing the ERROR logging level.

INFO class-attribute instance-attribute

INFO = 'INFO'

An enum member representing the INFO logging level.

NONE class-attribute instance-attribute

NONE = 'NONE'

An enum member indicating no logging messages should be captured.

WARNING class-attribute instance-attribute

WARNING = 'WARNING'

An enum member representing the WARNING logging level.

configure_logging

configure_logging(
    *,
    log_console_level: Union[str, LoggingLevels] = INFO,
    log_file_level: Union[str, LoggingLevels] = DEBUG,
    log_file_directory: Union[str, PathLike[str], Path] | None = None,
    log_file_name: str | None = None,
    log_colored_output: bool = False
) -> Logger

Configure the logging for this package.

Note

After this function is called once, if it is called again, it will not perform any additional configuration. It will simply return the base logger for the package.

Parameters:
  • log_console_level (Union[str, LoggingLevels], default: INFO ) –

    The logging level to set for the console. Defaults to INFO. Set to LoggingLevels.NONE to disable all console logging/printouts except for certain warnings and exceptions.

  • log_file_level (Union[str, LoggingLevels], default: DEBUG ) –

    The logging level to set for the file. Defaults to DEBUG. Set to LoggingLevels.NONE to disable logging to a file entirely.

  • log_file_directory (Union[str, PathLike[str], Path] | None, default: None ) –

    The directory to save log files to. Defaults to “./logs” in the current working directory.

  • log_file_name (str | None, default: None ) –

    The name of the log file to save the logs to. Defaults to a timestamped name with the .log extension.

  • log_colored_output (bool, default: False ) –

    Whether to use colored output from the colorlog package for the console. Defaults to False.

Returns:
  • Logger

    The base logger for the package, this base logger can also be accessed using logging.getLogger(tekhsi.PACKAGE_NAME).