--format, which can be one of html, plain, json, or json-plain, and
--timestamp-format, which controls the output format of timestamps in plain mode
html is what we do today, and remains the default. plain is useful for a human investigating logs in a text editor, where ANSI escape sequences would get in the way. json and json-plain structure each line as a JSON object, which is more easily consumed by machine, keeping the line content and line metadata (timestamp) separate.
Since removing all ANSI escapes in plain mode would drop timestamp codes, it makes sense to have a way to optionally include the timestamps in plain output, with some configurable formatting. Hence --timestamp-format.
There's a case for making --timestamp-format have useful effects when using html format, but this requires a bit of thought (both the timestamp format itself, and the XML processing instruction "element" containing it, should be configurable).
(no timestamp) Weather for City: Berlin, Germany
(no timestamp)
(no timestamp) .-. Moderate or heavy rain with thunder
(no timestamp) ( ). 2 – 6 °C
(no timestamp) (___(__) → 21 km/h
(no timestamp) ‚‘⚡‘‚⚡‚‘ 8 km
(no timestamp) ‚’‚’⚡’‚’ 2.4 mm
This adds two new flags:
--format
, which can be one ofhtml
,plain
,json
, orjson-plain
, and--timestamp-format
, which controls the output format of timestamps in plain modehtml
is what we do today, and remains the default.plain
is useful for a human investigating logs in a text editor, where ANSI escape sequences would get in the way.json
andjson-plain
structure each line as a JSON object, which is more easily consumed by machine, keeping the line content and line metadata (timestamp) separate.Since removing all ANSI escapes in
plain
mode would drop timestamp codes, it makes sense to have a way to optionally include the timestamps inplain
output, with some configurable formatting. Hence--timestamp-format
.There's a case for making
--timestamp-format
have useful effects when usinghtml
format, but this requires a bit of thought (both the timestamp format itself, and the XML processing instruction "element" containing it, should be configurable).Example outputs