diff --git a/app/journal.py b/app/journal.py index 16bd00e..a628f26 100644 --- a/app/journal.py +++ b/app/journal.py @@ -44,7 +44,9 @@ def format_entries(entries: list[dict[str, Any]]) -> list[dict[str, Any]]: Entries without a realtime timestamp are dropped. The local time is formatted as HH:MM:SS (invalid timestamps render as an empty string), PRIORITY defaults to 6 (info), and the identifier falls back - SYSLOG_IDENTIFIER -> _COMM -> _PID. + SYSLOG_IDENTIFIER -> _COMM -> _PID. A MESSAGE that is a JSON array — + journald encodes non-UTF-8 payloads as byte lists and multi-value + fields as string lists — is decoded or joined into a single line. Args: entries: dicts from parse_lines. @@ -67,7 +69,13 @@ def format_entries(entries: list[dict[str, Any]]) -> list[dict[str, Any]]: prio = int(e.get("PRIORITY", "6")) except ValueError: prio = 6 - msg = e.get("MESSAGE", "").rstrip("\n") + raw_msg: str | list[Any] | None = e.get("MESSAGE") + if isinstance(raw_msg, list): + if raw_msg and all(isinstance(m, int) for m in raw_msg): + raw_msg = bytes(raw_msg).decode("utf-8", errors="replace") + else: + raw_msg = " ".join(str(m) for m in raw_msg) + msg = (raw_msg or "").rstrip("\n") out.append( { "stamp": stamp,