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

readme mixin doc: wrong sample code #951

Closed
hraban opened this issue Jan 14, 2021 · 5 comments · Fixed by #952
Closed

readme mixin doc: wrong sample code #951

hraban opened this issue Jan 14, 2021 · 5 comments · Fixed by #952

Comments

@hraban
Copy link
Contributor

hraban commented Jan 14, 2021

The section on mixins in the readme has the following code:

const mixin = {
    appName: 'My app'
}

const logger = pino({
    mixin(obj) {
        return {
          description: obj.description
        }
    }
})

pino.info({
    description: 'Ok'
}, 'Message 1')
// {"level":30,"time":1591195061437,"pid":16012,"hostname":"x","appName":"My app","description":"Ok" "msg":"Message 1"}
pino.info('Message 2')
// {"level":30,"time":1591195061437,"pid":16012,"hostname":"x","appName":"My app","description":"Ok","msg":"Message 2"}
// Note: the second log contains "description":"Ok" text, even if it was not provided.

but (after fixing the last two pino references to logger), the prophecy in the logs doesn't actually come to be.

What was this bit of code intended to illustrate?

https://github.com/pinojs/pino/blob/master/docs/api.md#mixin-function

@jsumners
Copy link
Member

#857

@hraban
Copy link
Contributor Author

hraban commented Jan 15, 2021

Interesting. That snippet made sense as merged in that PR, but has since been edited to lose its intended meaning.

@mcollina
Copy link
Member

I think we made a mistake in #928. Would you like to send a PR to fix?

hraban added a commit to hraban/pino that referenced this issue Jan 15, 2021
Restores the original semantics introduced by afb639c (pinojs#857).

Reverts the changes to this documentation from 6e50d72 (pinojs#928) and
6c42f14 (pinojs#926).

Fixes pinojs#951.
@hraban
Copy link
Contributor Author

hraban commented Jan 15, 2021

PR: #952

@github-actions
Copy link

github-actions bot commented Feb 4, 2022

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

Successfully merging a pull request may close this issue.

3 participants