pino-pretty
pino-pretty copied to clipboard
How can we use pino-pretty with non-development defaults?
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.
I believe that PR shows a change to the documentation that would indicate how to reformat the time.
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.
Configuration files are supported: https://github.com/pinojs/pino-pretty/blob/849f0fc907adc3df30e7290b7fc091a055a30e51/bin.js#L23-L32
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?
I believe all of the source code is available for you to review.
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.
You are welcome to submit pull requests to improve documentation and add desired features.