pino-pretty icon indicating copy to clipboard operation
pino-pretty copied to clipboard

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

Open n4zukker opened this issue 1 year ago • 7 comments

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

pino-pretty -t

no longer

  • shows the SYS:standard option (timestamp with year, month, day, time in UTC)
  • shows the hostname

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.

n4zukker avatar Feb 01 '23 14:02 n4zukker

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

jsumners avatar Feb 01 '23 14:02 jsumners

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.

n4zukker avatar Feb 01 '23 15:02 n4zukker

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

jsumners avatar Feb 02 '23 13:02 jsumners

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?

n4zukker avatar Feb 02 '23 13:02 n4zukker

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

jsumners avatar Feb 02 '23 13:02 jsumners

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.

n4zukker avatar Feb 02 '23 13:02 n4zukker

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

jsumners avatar Feb 02 '23 13:02 jsumners