pinojs/pino

Overriding messageKey not working

Closed this issue · 1 comments

Hi Team,

I'm just getting started with Pino, and try to override the messageKey as mentioned in the documentation. But it's always using the default msg as key.

My config

const formatters = {
    level (label) {
      return { severity : label }
    }
  }
const logger = require('pino')({
    messageKey: 'message',
    browser: {
        asObject: true, 
        formatters: formatters,
        serialize: true,
        write: (o) => {
            console.log(JSON.stringify(o))
          }
    },
    base: undefined,
    timestamp: false,
    level: 'info',
})

 logger.info(`Random name is some name`)
  logger.warn("experimenting warning")
  logger.error("Evil, program failed")

and the output is:
{"severity":"info","msg":"Random name is relevant-indigo"}
{"severity":"warn","msg":"experimenting warning"}
{"severity":"error","msg":"Evil, program failed"}

like to have message as key instead of msg.

Please help with the right config to achieve the expected result.

Additional info:
Pino version: 9.1.0
Tested with cloudflare workers and hit the request from browser

please let me know if additional details are required.

Regards,
Raj

Thanks for reporting!

It does not look this is supported in the browser impl.
Would you like to send a Pull Request to address this issue? Remember to add unit tests.