Skip to content

Commit

Permalink
Tidy log from code review comments
Browse files Browse the repository at this point in the history
Co-authored-by: Jacob Wilkins <46597752+oerc0122@users.noreply.github.com>
  • Loading branch information
2 people authored and alinelena committed Apr 5, 2024
1 parent 91dd53f commit 0c2d229
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions janus_core/log.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,13 @@ class YamlFormatter(logging.Formatter): # numpydoc ignore=PR02
Format log message to convert new lines into a yaml list.
"""

FORMAT = (
"\n- timestamp: %(asctime)s\n"
" level: %(levelname)s\n"
" message: %(message)s\n"
" trace: %(module)s\n"
" line: %(lineno)d\n"
)
FORMAT = """
- timestamp: %(asctime)s
level: %(levelname)s
message: %(message)s
trace: %(module)s
line: %(lineno)d
"""

def __init__(self, *args, **kwargs) -> None:
"""
Expand Down Expand Up @@ -77,9 +77,10 @@ def format(self, record: logging.LogRecord) -> str:
record.msg = record.msg.replace('"', "'")

# Convert new lines into yaml list
msg = record.msg
record.msg = "\n" + "\n".join(
f' - "{line.strip()}"' for line in msg.split("\n") if line.strip()
f' - "{line.strip()}"'
for line in record.msg.splitlines()
if line.strip()
)
return super().format(record)

Expand Down

0 comments on commit 0c2d229

Please sign in to comment.