Logging¶

class PatcherLog[source]¶
static setup_logger(name: str | None = None, level: int | None = 20) Logger[source]¶

Configures and returns the Patcher logger with a rotating file handler.

Pure stdlib, no terminal output. Console / colored output is installed separately by the CLI via patcher.cli.terminal_logger.install_terminal_handler(); library callers get file logging only.

Parameters:
  • name (str | None) – Name of the logger, defaults to "Patcher".

  • level (int | None) – Logging level for the file handler. Defaults to INFO.

Returns:

The configured logger.

Return type:

Logger

static setup_child_logger(childName: str, loggerName: str | None = None) Logger[source]¶

Setup a child logger for a specified context.

Parameters:
  • childName (str) – The name of the child logger.

  • loggerName (str | None) – The name of the parent logger, defaults to "Patcher".

Returns:

The configured child logger.

Return type:

Logger

static custom_excepthook(exc_type: Type[BaseException], exc_value: BaseException, exc_traceback: TracebackType | None) None[source]¶

Logs unhandled exceptions to Patcher’s log file. Pure file logging, no terminal output. The CLI installs a chained excepthook that adds user-facing stderr messages on top of this one (see patcher.cli.terminal_logger.install_terminal_excepthook()).

KeyboardInterrupt is treated as a graceful exit (logged at INFO, process exits 130). All other uncaught exceptions are logged at ERROR.

Parameters:
  • exc_type (Type[BaseException]) – The class of the exception raised.

  • exc_value (BaseException) – The instance of the exception raised.

  • exc_traceback (TracebackType | None) – The traceback object associated with the exception.

Return type:

None

class LogMe(class_name: str)[source]¶

Thin wrapper around a stdlib logging.Logger scoped to a class name. Adds nothing beyond the file logging configured by PatcherLog.setup_logger(); terminal-color output is the CLI’s responsibility.

Parameters:

class_name (str) – The name of the class for which the logger is being set up.