pinojs / pino

🌲 super fast, all natural json logger
http://getpino.io
MIT License
14.21k stars 875 forks source link

How to pretty print logs after it was logged into a file as JSON? #250

Closed hadisinaee closed 7 years ago

hadisinaee commented 7 years ago

Hi :)

Is there any way to pretty print logs after they are saved into a file as JSON format? I mean, suppose we have the following log saved into file:

{"pid":2640,"hostname":"hdhd-srv","level":30,"time":1496236280290,"msg":"API endpoints are configured (NODE_ENV= PROD)","app":"api-server","tags":"dev","t":1496236280289,"ip":"localhost","port":"8085","v":1}
{"pid":2640,"hostname":"hdhd-srv","level":30,"time":1496236280838,"msg":"nothing to be cached","app":"api-server","tags":"dev","t":1496236280838,"v":1}
{"pid":2640,"hostname":"hdhd-srv","level":30,"time":1496236280838,"msg":"api server is running :)","app":"api-server","tags":"dev","t":1496236280838,"v":1}

Then we can do something like the following:

cat logs | ./node_modules/pino/pretty.js 

and it will print in the way pretty prints?

jsumners commented 7 years ago

cat logs | pino

mcollina commented 7 years ago

You will need to install pino globally for that. You can also use pino-colada. Il giorno mer 31 mag 2017 alle 15:44 James Sumners notifications@github.com ha scritto:

cat logs | pino

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/pinojs/pino/issues/250#issuecomment-305190934, or mute the thread https://github.com/notifications/unsubscribe-auth/AADL4yR8373i0bMq6hAzyf6NUPCMqPKMks5r_W7WgaJpZM4Nroza .

hadisinaee commented 7 years ago

Thank you @jsumners @mcollina :+1: I tested the following and it worked. I think I don't need to install it globally:

cat logs | ./node_modules/pino/bin.js
github-actions[bot] commented 2 years ago

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.