CustomLogger#
- class src.CustomLogger.CustomLogger(banner: str = '', log_file_path: str | None = None, max_old_logs: int = 25)[source]#
Bases:
Formatter
Custom logger for colored terminal and file logging with sectioning and log rotation.
- Parameters:
banner (str) – Banner to display at the top of logs.
log_file_path (str) – Path to the log file.
max_old_logs (int) – Maximum number of old log files to keep.
- COLORS = {'CRITICAL': '‼', 'DEBUG': '•', 'ERROR': '✖', 'INFO': '✔', 'WARNING': '⚠'}#
- append_log_to_file(line: str, filename: str | None = None) None [source]#
Append a log line to the log file.
- Parameters:
line (str) – Log line.
filename (str) – Optional log file path.
- format(record: LogRecord) str [source]#
Format a log record for file output.
- Parameters:
record (logging.LogRecord) – Log record.
- Returns:
Formatted log message.
- Return type:
str
- get_buffers() Tuple[List[Any], List[Any], str] [source]#
Get the terminal and file log buffers and the banner.
- Returns:
(terminal_buffer, file_buffer, banner)
- Return type:
tuple