Logger

Inheritance diagram of src.logger.Logger

Provides a centralised logging manager for the application.

module:

logger

author:

Le Bars, Yoann

class src.logger.Logger(args: CmdLineArgs)[source]

Bases: object

Manages application logging based on command-line arguments.

This class sets up a custom Qt message handler to filter logs by level and route them to the console, a file, or syslog as specified by the user.

Variables:
  • _args (CmdLineArgs) – The parsed command-line arguments.

  • _active_levels (set[int]) – The set of QtMsgType levels to log.

  • _level_prefixes (dict[int, str]) – Prefixes for each log level.

  • _log_file (TextIO | None) – An open file handle for the log file, or None.

  • _lock (Lock) – A lock to ensure thread-safe access to shared resources.

cleanup() None[source]

Cleans up logging resources and restores the default message handler.

message_handler(mode: QtMsgType, _context: QMessageLogContext, msg: str)[source]

A custom Qt message handler that filters, formats, and routes log messages.

Parameters:
  • mode (QtMsgType) – The type/level of the message.

  • _context (QMessageLogContext) – The context information (unused).

  • msg (str) – The log message.