Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to have JSON log output to terminal (iTerm2) pretty-printed on screen?

I am working with a KeystoneJS project whose log output looks like this:

enter image description here

If I cut it out and paste into my IDE (WebStorm) I can edit it so that it pretty prints nicely and I can read it much more easily

enter image description here

Is there a way to have iTerm2 automatically do this pretty-printing of all JSON written to screen? A plugin, a setting I've missed, or...? (I have no control over how KeystoneJS prints the log).

like image 814
Cerulean Avatar asked Dec 02 '25 23:12

Cerulean


1 Answers

I developed a command line tool to view json log (see https://github.com/qiangyt/jog). It is just like 'tail -f log-file' but it's for json log.

The output is not pretty-printed JSON, instead, it outputs regular flat lines. So it seems not exactly matches your needs, but if your target is just to easily view JSON log line, I guess it is useful for you. If not, let me know, it's easy and happy for me to add a new feature.

It's written using GO, and the cross-platform binaries are downloadable via https://github.com/qiangyt/jog/releases.

Not document how to configure it very well, but it works properly by default,and I'm happy to get issue report or new feature request.

like image 80
Yiting Qiang Avatar answered Dec 04 '25 13:12

Yiting Qiang