Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Overriding messageKey not working #1978

Closed
its-raj21 opened this issue May 17, 2024 · 2 comments · Fixed by #1980
Closed

Overriding messageKey not working #1978

its-raj21 opened this issue May 17, 2024 · 2 comments · Fixed by #1980

Comments

@its-raj21
Copy link

its-raj21 commented May 17, 2024

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

@mcollina
Copy link
Member

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.

Copy link

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Jun 21, 2024
# for free to subscribe to this conversation on GitHub. Already have an account? #.
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants