Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Revert "Avoid data loss with conflicting 'msg' values." #882

Merged
merged 2 commits into from
Aug 1, 2020

Conversation

jsumners
Copy link
Member

Reverts #876

This causes issues in dependent applications. See fastify/fastify#2453

To get the same effect, use the log method hook:

'use strict'

const log = require('pino')({
  level: 'debug',
  hooks: {
    logMethod (inputArgs, method) {
      if (inputArgs.length === 2 && inputArgs[0].msg) {
       inputArgs[0].originalMessage = inputArgs[0].msg
      }
      return method.apply(this, inputArgs)
    }
  }
})

log.info('no original message')
log.info({ msg: 'mapped to originalMsg' }, 'a message')

// {"level":30,"time":1596195825857,"pid":48580,"hostname":"mini2018","msg":"no original message"}
// {"level":30,"time":1596195825858,"pid":48580,"hostname":"mini2018","msg":"a message","originalMessage":"mapped to originalMsg","originalMsg":"mapped to originalMsg"}

cc: @markstos

@jsumners jsumners requested a review from mcollina July 31, 2020 22:18
@mcollina
Copy link
Member

mcollina commented Aug 1, 2020

Could you add that info to the docs as well, maybe in help?

@jsumners jsumners changed the title Revert "Avoid data loss with conflictig 'msg' values." Revert "Avoid data loss with conflicting 'msg' values." Aug 1, 2020
@jsumners
Copy link
Member Author

jsumners commented Aug 1, 2020

@mcollina updated.

Copy link
Member

@mcollina mcollina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@jsumners jsumners merged commit a4935cc into master Aug 1, 2020
@jsumners jsumners deleted the revert-876-originalMsg branch August 1, 2020 21:01
@github-actions
Copy link

github-actions bot commented Feb 2, 2022

This pull request 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 Feb 2, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants