Logger.py#

Logging and monitoring for evolutionary experiments.

Provides console and file-based logging with ANSI color formatting, live plot launching, and workspace archival for experiment results.

class Logger.Logger(explanation: str, logger_config: LoggerConfig)[source]#

Level-gated logger with monitor file output and live plot integration.

Writes timestamped entries to both stdout and a monitor file, supports ANSI-colored severity prefixes, and can launch gnome-terminal-based live plotting windows for experiment visualization.

__init__(explanation: str, logger_config: LoggerConfig)[source]#

Set up log files, clear workspace data logs, and start the monitor.

Parameters:
  • explanation (str) – Human-readable description of the experiment.

  • logger_config (LoggerConfig) – Configuration controlling log paths, verbosity, and plot behavior.

__init_monitor()#

Initialize the monitor file header, plots directory, and live plot windows.

Writes the experiment banner to the monitor file, resets the plots directory, and optionally launches a live plotting terminal.

log_critical(level, *msg)[source]#

Log a critical message with red ANSI formatting.

log_error(level, *msg)[source]#

Log an error message with red ANSI formatting.

log_event(level, *msg)[source]#

Log a general event to stdout and the monitor file if level permits.

log_generation(population, epoch_time)[source]#

Log a generation summary including current and overall best fitness.

Parameters:
  • population (Population) – The population whose best circuits are reported.

  • epoch_time (float) – Wall-clock seconds elapsed during the epoch.

log_info(level, *msg)[source]#

Log an informational message with blue ANSI formatting.

log_monitor(prefix, *msg)[source]#

Write a timestamped message directly to the monitor log file.

log_warning(level, *msg)[source]#

Log a warning message with yellow ANSI formatting.

save_workspace(directory)[source]#

Close the monitor file and archive the workspace to a timestamped directory.

class Logger.LoggerConfig(plots_dir: Path, launch_plots: bool, is_sensitivity: bool, frame_interval: int, log_file: Path, log_level: int, save_log: bool, datetime_format: str)[source]#

Configuration for Logger output, plot launching, and file paths.

Consumed by Logger.__init__ to control verbosity, plot behavior, and workspace log destinations.