mirror of
https://github.com/theroyallab/tabbyAPI.git
synced 2026-03-15 00:07:28 +00:00
Logger: Add timestamps
Was against this for a while due to the length of timestamps clogging the console, but it makes sense to know when something goes wrong. Signed-off-by: kingbri <8082010+kingbri1@users.noreply.github.com>
This commit is contained in:
@@ -52,6 +52,10 @@ def _log_formatter(record: dict):
|
||||
"ERROR": "red",
|
||||
"CRITICAL": "bold white on red",
|
||||
}
|
||||
|
||||
time = record.get("time")
|
||||
colored_time = f"[grey37]{time:YYYY-DD-MM HH:mm:ss.SSS}[/grey37]"
|
||||
|
||||
level = record.get("level")
|
||||
level_color = color_map.get(level.name, "cyan")
|
||||
colored_level = f"[{level_color}]{level.name}[/{level_color}]:"
|
||||
@@ -69,9 +73,11 @@ def _log_formatter(record: dict):
|
||||
|
||||
fmt = ""
|
||||
if len(lines) > 1:
|
||||
fmt = "\n".join([f"{colored_level}{separator}{line}" for line in lines])
|
||||
fmt = "\n".join(
|
||||
[f"{colored_time} {colored_level}{separator}{line}" for line in lines]
|
||||
)
|
||||
else:
|
||||
fmt = f"{colored_level}{separator}{message}"
|
||||
fmt = f"{colored_time} {colored_level}{separator}{message}"
|
||||
|
||||
return fmt
|
||||
|
||||
|
||||
Reference in New Issue
Block a user