pinojs / pino-pretty

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

customLevels brake logging with transports #417

Closed Sveeborg closed 1 year ago

Sveeborg commented 1 year ago

Hello!

pino 8.11.0

When customLevels is defined and transport level is equal to custom level, logging does not work, but no exceptions occur.

This works fine:

const transport = pino.transport({
  targets: [
    {
      level: 'info',
      target: 'pino-pretty',
      options: {
        translateTime: "yyyy-mm-dd'T'HH:MM:ss'Z'",
        ignore: 'pid,hostname',
        customLevels: 'serious:35',
        customColors: 'serious:green',
        useOnlyCustomProps: false,
      },
    },
  ],
})

const LOG = pino(
  {
    level: 'trace',
    customLevels: {
      serious: 35,
    },
  },
  transport
)

This does not work:

const transport = pino.transport({
  targets: [
    {
      level: 'serious',
      target: 'pino-pretty',
      options: {
        translateTime: "yyyy-mm-dd'T'HH:MM:ss'Z'",
        ignore: 'pid,hostname',
        customLevels: 'serious:35',
        customColors: 'serious:green',
        useOnlyCustomProps: false,
      },
    },
  ],
})

const LOG = pino(
  {
    level: 'trace',
    customLevels: {
      serious: 35,
    },
  },
  transport
)

Problem is not in pino-pretti. Another transports behave similarly.

If I add cusom level into pino levels.js, all works fine:

// pino/lib/levels.js
// ...
const levels = {
  trace: 10,
  debug: 20,
  info: 30,
  serious: 35,
  warn: 40,
  error: 50,
  fatal: 60
}
// ...
Sveeborg commented 1 year ago

Sorry! Its issue for pino, not pino-pretty.