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

Documentation shows colorization functions, but they don't seem to exist or work #474

Open
nsoft opened this issue Oct 18, 2023 · 1 comment

Comments

@nsoft
Copy link

nsoft commented Oct 18, 2023

If I define a log target with options that include customPretifiers as shown in Readme.md two problems arise:

  1. The functions shown in the example don't seem to exist
  2. Even if I define my own version of the function one gets a data clone error...

https://github.com/pinojs/pino-pretty/blob/master/Readme.md#handling-non-serializable-options suggests a possible solution, but it didn't seem to work (at least not for trying to colorize an attribute from the merge object)

stdLogTarget.ts

function colorYellow(script) {
  return "\x1b[33m foo "+ script + "\x1b[0"
}

module.exports = opts => require('pino-pretty')({
  ...opts,
  customPrettifiers: {
    script: (script: any) => colorYellow(script)
  }
})

logger.ts

const stdLogTarget = (level: strig) => ({
  target: './stdLogTarget'

That runs but neither the color nor the "foo" is added. (yes naming of some things needs improvement, not final form)

I think the docs make clear that the functions listed don't exist (or if they do say where to find them), and provide examples that are in working form.

@jsumners
Copy link
Member

The linked example is an example of potential user code, not an example of what is provided by the library. Improvements to the documentation are welcome.

As for any error, please provide the text of the error. Also, please provide a minimal reproducible example. Doing so will help us diagnose your issue. It should be the bare minimum code needed to trigger the issue, and easily runnable without any changes or extra code.

You may use a GitHub repository to host the code if it is too much to fit in a code block (or two).

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