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

Fixed stream metadata loss during prettification #780

Merged
merged 3 commits into from Feb 28, 2020
Merged

Fixed stream metadata loss during prettification #780

merged 3 commits into from Feb 28, 2020

Conversation

nlapshin
Copy link
Contributor

@nlapshin nlapshin commented Feb 28, 2020

For streams with Symbol('metadata') true flag, pino metadata was lost during prettification.

RE: pinojs/pino-multi-stream#31

For streams with Symbol('metadata') true flag, pino metadata was lost during prettification
lib/tools.js Outdated
flushSync () {
if (warned) {
return
}
warned = true
dest.write(pretty(Object.assign({
dest.write.call(this.destStreamContext, pretty(Object.assign({
Copy link
Member

Choose a reason for hiding this comment

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

Copying streams metadata might cause significant issues. I would just attach the properties to the stream itself, mutating it.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed it

Copy link
Member

Choose a reason for hiding this comment

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

I think you can do something like:

function setMetadataProps (dest, that) {
      if (dest[needsMetadataGsym] === true) {
        dest.lastLevel = that.lastLevel
        dest.lastMsg = that.lastMsg
        dest.lastObj = that.lastObj
        dest.lastTime = that.lastTime
        dest.lastLogger = that.lastLogger
      }
}

and then call in both places.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Created setMetadataProps function

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

@github-actions
Copy link

github-actions bot commented Feb 3, 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 3, 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.

None yet

2 participants