spacr.qt.logging_util

Qt-side extension of the package-scope logger.

Delegates all file-handler configuration to spacr.logging_util and adds a QtLogHandler that emits every formatted record over a Qt signal so widgets on the main thread can display them without cross-thread violations.

Two sinks end up wired at spacr-qt startup:

  1. The rotating file handler at ~/.spacr/logs/spacr.log (installed by spacr.logging_util).

  2. The QtLogHandler here — ConsolePanel connects to its record_ready(str, int) signal.

Public API:

setup_logging(…) — call once early in launch(). get_signal_handler() — the shared QtLogHandler instance. log_path() — absolute path of the rotating log file.

Module Contents

spacr.qt.logging_util.log_dir() pathlib.Path[source]

Return the folder where spacr log files live.

Alias for spacr.logging_util.log_dir().

spacr.qt.logging_util.log_path() pathlib.Path[source]

Return the absolute path of the rotating log file.

Alias for spacr.logging_util.log_path().

class spacr.qt.logging_util.QtLogHandler(level: int = logging.INFO)[source]

Bases: PySide6.QtCore.QObject, logging.Handler

A logging.Handler that emits every formatted record over a Qt signal so QWidget slots (running on the main thread) can display them without cross-thread violations.

Variables:

record_ready – signal (formatted_line, levelno) emitted once per record.

record_ready[source]
emit(record: logging.LogRecord) None[source]

Format and re-emit record over record_ready.

spacr.qt.logging_util.get_signal_handler() QtLogHandler[source]

Return the shared QtLogHandler. Instantiated on first access.

spacr.qt.logging_util.setup_logging(level: int = logging.INFO, console_level: int = logging.INFO) None[source]

Install the file handler + the Qt signal handler on the root logger. Idempotent — safe to call more than once.

Parameters:
  • level – minimum record level for the rotating file handler.

  • console_level – minimum record level for the Qt signal handler (i.e. what ConsolePanel receives).

spacr.qt.logging_util.get_logger(name: str = 'spacr.qt') logging.Logger[source]

Convenience wrapper — returns a child logger under spacr.qt.

Parameters:

name – logger name, defaults to "spacr.qt".