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

Allow setting customPrettifiers from the cli #515

Open
jedahan opened this issue Jun 6, 2024 · 2 comments
Open

Allow setting customPrettifiers from the cli #515

jedahan opened this issue Jun 6, 2024 · 2 comments

Comments

@jedahan
Copy link

jedahan commented Jun 6, 2024

I like that our logging code does not need to care if its being pretty-printed or not, just adding | pretty-print to our dev scripts is good separation.

I would like to customize how our objects are pretty-printed, like customPrettifiers work. Is there a way to tell pino-pretty cli to load customPrettifiers from a file? Would this be a desired feature? Do you have tips on how to start implementing said feature?

Thanks

@mcollina
Copy link
Member

mcollina commented Jun 8, 2024

I think it should be possible via the use of a config file:

const joycon = new JoyCon({
.

@tommiv
Copy link

tommiv commented Jul 3, 2024

Came here with the same question and just checked it out. It does work indeed. Here's how I "deserialize" a JS stacktrace which is hard to read otherwise:

// pino-pretty.config.js
module.exports = {
  timestampKey: 'ts',
  messageKey: 'message',
  ignore: 'type,serviceName',
  customPrettifiers: {
    trace: (trace) => '\n' + trace.replace(/\\n/g, '\n')
  }
}

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

3 participants