Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
n4zukker opened this issue Feb 1, 2023 · 7 comments
Open

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

n4zukker opened this issue Feb 1, 2023 · 7 comments

Comments

@n4zukker
Copy link

n4zukker commented Feb 1, 2023

This PR, #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.

@jsumners
Copy link
Member

jsumners commented Feb 1, 2023

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

@n4zukker
Copy link
Author

n4zukker commented Feb 1, 2023

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
Copy link
Member

jsumners commented Feb 2, 2023

Configuration files are supported:

pino-pretty/bin.js

Lines 23 to 32 in 849f0fc

const joycon = new JoyCon({
parseJSON,
files: [
'pino-pretty.config.cjs',
'pino-pretty.config.js',
'.pino-prettyrc',
'.pino-prettyrc.json'
],
stopDir: path.dirname(process.cwd())
})

@n4zukker
Copy link
Author

n4zukker commented Feb 2, 2023

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
Copy link
Member

jsumners commented Feb 2, 2023

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

@n4zukker
Copy link
Author

n4zukker commented Feb 2, 2023

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
Copy link
Member

jsumners commented Feb 2, 2023

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants