pinojs / pino-pretty

🌲Basic prettifier for Pino log lines
MIT License
1.27k stars 150 forks source link

How can we use pino-pretty with non-development defaults? #397

Open n4zukker opened 1 year ago

n4zukker commented 1 year ago

This PR, https://github.com/pinojs/pino-pretty/pull/366, changed the default options for pino-pretty so that

pino-pretty -t

no longer

How can I get these back? Is there an easy way (environment variable, config file, command line option) to get pino-pretty working again for non-development systems?

We use pino for logs in our kubernetes environment. When people create issues, I always tell them to paste the relevant logs using pino-pretty -t. That used to record the hostname (which micro-service made the log) and the time independent of wherever in the world the person is. But I noticed that recently, that key information is lost.

pino-pretty --include hostname shows me the hostname but it excludes other properties. So it is less than useful.

jsumners commented 1 year ago

I believe that PR shows a change to the documentation that would indicate how to reformat the time.

n4zukker commented 1 year ago

Yes. pino-pretty -t SYS:standard will give the time the way I want it. I'm also looking for a way to get the hostname back. And a way to set this as the default so that I and my team don't have to type a lengthy command to get the logs.

jsumners commented 1 year ago

Configuration files are supported: https://github.com/pinojs/pino-pretty/blob/849f0fc907adc3df30e7290b7fc091a055a30e51/bin.js#L23-L32

n4zukker commented 1 year ago

Do you have an example of a configuration file? Could you please show me what I should put in there to get the hostname back, so that the output looks like the output of pino-pretty, v8?

jsumners commented 1 year ago

I believe all of the source code is available for you to review.

n4zukker commented 1 year ago

For those of you who don't want to look through the source, it seems that putting a file .pino-prettyrc in the current directory with this JSON will get us back to the pino-pretty that we know and love.

$ cat .pino-prettyrc
{
  "translateTime": "SYS:standard",
  "ignore": ""
}

It would be nice if there was a way to get this file to be used regardless of the current directory. But I guess each of us is expected to read through the source code to find that out.

jsumners commented 1 year ago

You are welcome to submit pull requests to improve documentation and add desired features.