pinojs / pino-pretty

🌲Basic prettifier for Pino log lines
MIT License
1.27k stars 150 forks source link

Change the way of passing customLevels in code level #399

Closed ademarsj closed 1 year ago

ademarsj commented 1 year ago

Due to pino handle customLevels as object often people will try to use like that in pino-pretty, so receiving a object instead of a string when using in code level as a transporter in pino would improve the understanding and use of the lib.

To work like that, instead of transforming the object to string and keeping two instances who had the same value but in different types:

const levels = {
  http: 10,
  info: 30,
  debug: 35,
  warn: 40,
  normal_error: 50,
  fatal_error: 60,
}

const log = pino(
  {
    customLevels: levels,
    useOnlyCustomLevels: true,
    level: 'http'
  },
  pretty({
  colorize: true,
  levelFirst: true,
  customLevels: levels,
  })
);
ademarsj commented 1 year ago

I would like to work on that, so i will send a PR as soon as i can. (Sorry for closing the PR, i missed the click...)