Terminal Logger¶
Click-backed terminal output for the Patcher logger.
This module is the CLI’s adapter onto patcher.core.logger.PatcherLog.
Installing a TerminalHandler adds colored level-prefixed output on top
of the always-present rotating file handler; library users who never import
patcher.cli get the file-only behavior with no asyncclick dependency.
Two install points:
install_terminal_handler(): attach the colored console handler. Call from the CLI entry point when--debugis set.install_terminal_excepthook(): chain a terminal-styled message ontopatcher.core.logger.PatcherLog.custom_excepthook()so unhandled exceptions surface a one-line stderr message in addition to the file log.
- class TerminalHandler(level=0)[source]¶
Logging handler that emits records as Rich-styled lines on stdout.
Maps each log level to a color so a debug run produces the same visual output the legacy in-class
click.echocalls did (magenta DEBUG, blue INFO, bold-yellow WARNING, bold-red ERROR). The leading\rpreserves the existing behavior of overwriting the current terminal line. Output routes through the sharedconsole.Initializes the instance - basically setting the formatter to None and the filter list to empty.
- install_terminal_handler(debug: bool) None[source]¶
Attach a
TerminalHandlerto the Patcher logger when in debug mode.Idempotent. Calling twice will not add duplicate handlers. No-op when
debugis False, so the standard CLI run (and any library import path) sees no terminal output beyond what callers explicitly emit.- Parameters:
debug (bool) – Whether the CLI was invoked with
--debug.- Return type:
None
- install_terminal_excepthook() None[source]¶
Chain a terminal-styled excepthook onto
custom_excepthook().The core hook logs unhandled exceptions to file. This wrapper additionally emits a one-line red error message and a hint about the log file to stderr, matching the legacy in-module behavior. Library callers who never import
patcher.cliare unaffected; theirsys.excepthookis not touched.- Return type:
None