Logging#

class PatcherLog[source]#

Configures Patcherโ€™s stdlib rotating file logger (under Application Support).

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._console.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._console.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]#

Per-class logger wrapper (self.log = LogMe(self.__class__.__name__)).

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.