experiment_runner.log_setup
Logging configuration for the xai4tsc standalone runner.
The console comes from the package’s xai4tsc.enable_logging(); the runner
adds colour to it and attaches its own file sinks: one experiment.log per run
and one log per model, each detached when its part of the run ends. Everything
targets the 'xai4tsc' named logger only - never the root logger - so the
package remains silent when imported outside the runner.
Console output tints whole lines above INFO when the stream is a terminal,
following the NO_COLOR and FORCE_COLOR conventions, so piped or redirected
output stays plain. INFO lines are left uncoloured, since they are the bulk of
the output. File sinks are never coloured, so a log file holds no escape codes.
Functions
|
Attach a file sink to the xai4tsc logger. |
|
Detach and close a file sink attached by |
Module Contents
- experiment_runner.log_setup.add_file_log(log_path: pathlib.Path, level: int | None = None) logging.Handler
Attach a file sink to the xai4tsc logger.
- Parameters:
log_path (Path) – Log file to write. Missing parent directories are created and an existing file is overwritten.
level (int, optional) – Level for this sink. If
None(default), the logger’s effective level.
- Returns:
The attached handler; pass it to
remove_file_log()to detach it. Without that, a later run or model in the same process would also write into this log.- Return type:
logging.Handler
- experiment_runner.log_setup.remove_file_log(handler: logging.Handler | None) None
Detach and close a file sink attached by
add_file_log().- Parameters:
handler (logging.Handler or None) – The handler to detach.
Noneis a no-op, so afinallyblock can call this unconditionally.