CodeEntropy.core.logging module¶
Logging configuration utilities for CodeEntropy.
This module configures consistent logging across the project with:
Rich console output (with tracebacks) for human-readable terminal logs
File handlers for main logs, error-only logs, command logs, and MDAnalysis logs
A singleton Rich Console instance with recording enabled, so terminal output can be exported to disk at the end of a run
The design keeps responsibilities separated: - ErrorFilter: filter logic only - LoggingConfig: handler creation, logger wiring, and exporting recorded output
- class CodeEntropy.core.logging.ErrorFilter(name='')[source]¶
Bases:
FilterAllow only ERROR and CRITICAL log records.
This filter is intended for the error file handler so that the file contains only high-severity records and does not include DEBUG/INFO/WARNING output.
- class CodeEntropy.core.logging.LoggingConfig(folder: str, level: int = 20)[source]¶
Bases:
objectConfigure project logging with Rich console output and file handlers.
This class wires a set of handlers onto the root logger and a few named loggers. It also provides a singleton Rich Console instance with recording enabled so that all console output can be exported to a text file later.
- Variables:
log_dir – Directory where log files are written.
level – Base logging level for the root logger and file handlers.
console – Shared Rich Console instance used by RichHandler.
handlers – Mapping of handler name to handler instance.
- configure() Logger[source]¶
Attach configured handlers to the appropriate loggers.
This method: - Attaches rich/main/error handlers to the root logger - Attaches command handler to the ‘commands’ logger (non-propagating) - Attaches MDAnalysis handler to the ‘MDAnalysis’ logger (non-propagating)
- Returns:
A logger for the current module.
- export_console(filename: str = 'program_output.txt') None[source]¶
Save recorded console output to a file.
- Parameters:
filename – Output filename inside the log directory.