|
|
|
|
@ -11,6 +11,17 @@ from src.enums import OptimumOHEnum
|
|
|
|
|
|
|
|
|
|
LOG_FORMAT_DEBUG = "%(levelname)s:%(message)s:%(pathname)s:%(funcName)s:%(lineno)d"
|
|
|
|
|
|
|
|
|
|
# ANSI Color Codes
|
|
|
|
|
RESET = "\033[0m"
|
|
|
|
|
COLORS = {
|
|
|
|
|
"DEBUG": "\033[36m", # Cyan
|
|
|
|
|
"INFO": "\033[32m", # Green
|
|
|
|
|
"WARNING": "\033[33m", # Yellow
|
|
|
|
|
"WARN": "\033[33m", # Yellow
|
|
|
|
|
"ERROR": "\033[31m", # Red
|
|
|
|
|
"CRITICAL": "\033[1;31m", # Bold Red
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class LogLevels(OptimumOHEnum):
|
|
|
|
|
info = "INFO"
|
|
|
|
|
@ -67,7 +78,14 @@ class JSONFormatter(logging.Formatter):
|
|
|
|
|
if key not in standard_attrs:
|
|
|
|
|
log_record[key] = value
|
|
|
|
|
|
|
|
|
|
return json.dumps(log_record)
|
|
|
|
|
log_json = json.dumps(log_record)
|
|
|
|
|
|
|
|
|
|
# Apply color if the output is a terminal
|
|
|
|
|
if sys.stdout.isatty():
|
|
|
|
|
level_color = COLORS.get(record.levelname, "")
|
|
|
|
|
return f"{level_color}{log_json}{RESET}"
|
|
|
|
|
|
|
|
|
|
return log_json
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def configure_logging():
|
|
|
|
|
|