Skip to content

Commit

Permalink
Logger: Add timestamps
Browse files Browse the repository at this point in the history
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 <[email protected]>
  • Loading branch information
kingbri1 committed Feb 7, 2025
1 parent 54fda0d commit dcbf2de
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions common/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -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}]:"
Expand All @@ -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

Expand Down

1 comment on commit dcbf2de

@strikeoncmputrz
Copy link

@strikeoncmputrz strikeoncmputrz commented on dcbf2de Feb 8, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you!!! I am the guy who PR'd about changing the logging options a while ago. I eventually abandoned it because I recognized that it wasn't what the project was looking for. Still, this is a really excellent capability for collecting telemetry on exllamav2 / tabby. Appreciate all that you do!

Please sign in to comment.