potpyri.utils.logger
Logging utilities for the POTPyRI pipeline.
Provides a colored console and file logger with UTC timestamps for pipeline steps. Authors: Kerry Paterson, Charlie Kilpatrick.
Functions
|
Replace $RESET and $BOLD placeholders with ANSI codes or empty strings. |
|
Create and return a ColoredLogger writing to the given directory. |
Classes
|
Formatter that optionally colors the levelname in log records. |
|
Logger that writes to both console (colored) and a file (UTC, no color). |
- class potpyri.utils.logger.ColoredFormatter(msg, use_color=True)[source]
Bases:
FormatterFormatter that optionally colors the levelname in log records.
- format(record)[source]
Format the log record; optionally colorize levelname.
- class potpyri.utils.logger.ColoredLogger(filename)[source]
Bases:
LoggerLogger that writes to both console (colored) and a file (UTC, no color).
- close()[source]
Close and remove all handlers.
Call when the logger is no longer needed (e.g., end of test or script) to avoid ResourceWarnings from unclosed file handles.
- shutdown()[source]
Shut down the logging system and flush all handlers.
- potpyri.utils.logger.formatter_message(message, use_color=True)[source]
Replace $RESET and $BOLD placeholders with ANSI codes or empty strings.
- Parameters:
message (
str) – Format string possibly containing $RESET and $BOLD.use_color (
bool, optional) – If True, insert color sequences; otherwise strip them. Default is True.
- Returns:
Message with placeholders substituted.
- Return type:
str
- potpyri.utils.logger.get_log(log_dir)[source]
Create and return a ColoredLogger writing to the given directory.
Log filename is generated as log_YYYYMMDD_HHMMSS.log (UTC).
- Parameters:
log_dir (
str) – Directory path for the log file.- Returns:
Logger instance with stream and file handlers.
- Return type: