pinojs/pino

serializers are applied twice in pino/browser

Closed this issue · 2 comments

Given the following configuration

let logger = pino({
    serializers: {
      extras(data) {
        return { serializedExtras: data };
      },
    },
    browser: {
      serialize: ['!stdSerializers.err', 'extras'],
      transmit: {
        level: 'info',
        send(level, logEvent) {
          console.log(JSON.stringify(logEvent));
        },
      },
    },
  })

 logger.info('This is an info', {
      extras: { a: 1 },
    })

the log is written as

{"ts":1715273299461,"messages":["This is an info",{"extras":{"serializedExtras":{"serializedExtras":{"a":1}}}}],"bindings":[],"level":{"label":"info","value":30}}

serializedExtras is nested twice in the log

Thanks for reporting! Would you like to send a Pull Request to address this issue? Remember to add unit tests.

Sure, raised a PR #1971