hedhyw / json-log-viewer

Interactive viewer for JSON logs.
MIT License
90 stars 8 forks source link

bug: When piping into jlv, colors are lost #105

Open kiesel opened 3 days ago

kiesel commented 3 days ago

When I run

$ some-command | jlv

I don't have colored log levels - different from when opening a file w/ jlv somelog.json.

Probably the interactive terminal detection goes wrong due to stdin being used?

hedhyw commented 3 days ago

could it be that some-command also uses colors?

Plain experiment:

echo '{"msg":"test","level":"debug"}' | jlv
kiesel commented 3 days ago

The experiment yields jlv with colored debug; however, the original program does in fact only emit json logs, nothing else. It is a nodejs process.

This sample, though, also shows colors:

$ node -e 'console.log(JSON.stringify({msg: "test", level: "debug"})); console.log(JSON.stringify({msg:"error", level: "error"}));' | jlv

I will investigate the original script.