Spaces:
Sleeping
Sleeping
File size: 768 Bytes
12ba16b |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# src/utils/logger.py
# A simple, centralized logging utility for Project Chimera.
import datetime
import config
def log(source, message, level="INFO", header=False):
"""
A centralized logging function.
- source: The component of the system generating the log (e.g., "CRC", "SFE").
- message: The log message.
- level: The severity of the message (e.g., "INFO", "WARN", "ERROR").
- header: If True, prints a decorative header for major events.
"""
if config.OPERATION_MODE == 'development' or level != "INFO":
timestamp = datetime.datetime.now().strftime("%H:%M:%S")
if header:
print(f"\n{'='*20} {message} {'='*20}")
else:
print(f"[{timestamp} | {source:<20} | {level:<5}] {message}")
|