json-log-viewer
json-log-viewer copied to clipboard
Document logfile format
After a few failed attempts of opening a log file, and digging into the tests and source, it looks like this is the logfile format expected by default:
{ "timestamp": "2018-09-12T05:41:37.562Z", "level": "debug", "message": "message 1", "data": "some data", "another": { "any": "thing" }}
{ "timestamp": "2018-09-12T05:41:36.566Z", "level": "info", "message": "message 2", "data": "some other data" }
{ "timestamp": "2018-09-12T05:41:35.571Z", "level": "warn", "message": "message 3" }
{ "timestamp": "2018-09-12T05:41:35.571Z", "level": "error", "message": "message 4" }
{ "timestamp": "2018-09-12T05:41:35.571Z", "level": "error", "message": "message 5" }
Notes:
- Each JSON object is a single line. Pretty printed JS objects won't work.
- levels are "debug" | "info" | "warn" | "error" (capitalization matters)
- objects should have fields "timestamp", "level", and "message". Any extra fields (e.g. "data" and "another" above) are included in the popup when hitting
<enter>
on the corresponding line in the main screen.
After fixing for the above, it's working: (except the {orange-fg}
issue but that's reported elsewhere (#5)).
main screen:
detail screen:
Another potential improvement would be better error detection and reporting. I copied the example config file to my home directory and subsequently forgot about it, then when I went to open a file formatted differently than the configuration specified, the output had "undefined" printed where the timestamp should have been.
Agree with this, it took me a while to get it and read the code.
Also would be nice to support pure JSON object files (I've logs that are just an array of objects... It would be easy to get them working, maybe using a command line flag for them).
Together with #16, where figuring out if it's just a numeric value should be enough to try to use Date to convert to the locale string