Skip to content

Commit

Permalink
Logging: Fix inconsistent formatting
Browse files Browse the repository at this point in the history
Some colorization was incorrect and the separator insertion has become
more robust.

Signed-off-by: kingbri <[email protected]>
  • Loading branch information
bdashore3 committed Mar 8, 2024
1 parent 30e31bd commit fc55c6d
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions common/logger.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,9 @@ def _log_formatter(record: dict) -> str:
}
level = record.get("level")
level_color = color_map.get(level.name, "cyan")
colored_level = f"[{level_color}]{level.name}[/{level_color}]:"

separator = " " * (9 - len(level.name))

message = unwrap(record.get("message"), "")
lines = message.splitlines()
Expand All @@ -57,12 +60,12 @@ def _log_formatter(record: dict) -> str:
if len(lines) > 1:
fmt = "\n".join(
[
f"[{level_color}]{level.name + ':' :<10}[/{level_color}]{line}"
f"{colored_level}{separator}{line}"
for line in lines
]
)
else:
fmt = f"[{level_color}]{level.name + ':' :<10}[/{level_color}]{message}"
fmt = f"{colored_level}{separator}{message}"

return fmt

Expand Down

0 comments on commit fc55c6d

Please sign in to comment.