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
Bind pino instance to prettifier #721
Bind pino instance to prettifier #721
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
@@ -96,7 +97,7 @@ function pino (...args) { | |||
assertDefaultLevelFound(level, customLevels, useOnlyCustomLevels) | |||
const levels = mappings(customLevels, useOnlyCustomLevels) | |||
|
|||
const instance = { | |||
Object.assign(instance, { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can we avoid doing this? It will slow down init time
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is called only once and the difference between Object.assign
and {}
will be nanoseconds. So Comparing to other code and node itself there will be less than statistical uncertainty.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is just run once.. this might be relevant only for serverless if at all.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actually this has a side effect, as all the definitions of the hidden class would not be done in the same place.
Can you revert?
(Good spot @davidmarkclements).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If instance is needed to be passed to normalize function then it should be defined before calling normalize. And normalize returns opts
that are used for constructing the instance. So I don't know what's the way of avoiding this.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@SkeLLLa how about resolving this so we can merge?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
.
That’s assuming that everyone uses child loggers instead of new instances.
I’ve seen the latter in the wild
…On Fri, 4 Oct 2019 at 14:48, Matteo Collina ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In pino.js <#721 (comment)>
:
> @@ -96,7 +97,7 @@ function pino (...args) {
assertDefaultLevelFound(level, customLevels, useOnlyCustomLevels)
const levels = mappings(customLevels, useOnlyCustomLevels)
- const instance = {
+ Object.assign(instance, {
This is just run once.. this might be relevant only for serverless if at
all.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#721?email_source=notifications&email_token=AAJCWPAN4VSBVXXSKMNR2WLQM43S3A5CNFSM4I5AVO32YY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCG5LS7Q#discussion_r331483001>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAJCWPGUIDQEDO6I6NJKXZTQM43S3ANCNFSM4I5AVO3Q>
.
|
I've seen that happen only at module scope/maybe 10 or 20 times within a project. In other terms, this does not sit in a hot path for me. |
Fair enough - do we know why we’re doing this though? I don’t fully see the
reason
…On Fri, 4 Oct 2019 at 14:55, Matteo Collina ***@***.***> wrote:
That’s assuming that everyone uses child loggers instead of new instances.
I’ve seen the latter in the wild
I've seen that happen only at module scope/maybe 10 or 20 times within a
project. In other terms, this does not sit in a hot path for me.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#721?email_source=notifications&email_token=AAJCWPEIGMM4XJSYVMYDAOLQM44KHA5CNFSM4I5AVO32YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEALRRTY#issuecomment-538384591>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAJCWPAAZFUY5WOXLHEYCYDQM44KHANCNFSM4I5AVO3Q>
.
|
Oh yeah that too Hahahah
…On Fri, 4 Oct 2019 at 14:58, Matteo Collina ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In pino.js <#721 (comment)>
:
> @@ -96,7 +97,7 @@ function pino (...args) {
assertDefaultLevelFound(level, customLevels, useOnlyCustomLevels)
const levels = mappings(customLevels, useOnlyCustomLevels)
- const instance = {
+ Object.assign(instance, {
Actually this has a side effect, as all the definitions of the hidden
class would not be done in the same place.
Can you revert?
(Good spot @davidmarkclements <https://github.com/davidmarkclements>).
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#721?email_source=notifications&email_token=AAJCWPA4M6BOOFJD2YBNDGTQM44YTA5CNFSM4I5AVO32YY3PNVWWK3TUL52HS4DFWFIHK3DMKJSXC5LFON2FEZLWNFSXPKTDN5WW2ZLOORPWSZGOCG5M4MI#discussion_r331487012>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AAJCWPHKUPDJ7IWNOSAAEBLQM44YTANCNFSM4I5AVO3Q>
.
|
@davidmarkclements have your concerns been addressed? |
@jsumners yeah lgtm |
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. |
This PR passes pino instance to prettifier function.
It can be used to access configured levels, for example, here https://github.com/pinojs/pino-pretty/blob/master/lib/colors.js#L32 levels are hardcoded and if there are
customLevels
setup, then it will not work correctly.Closes #720.
PS: I'm not a fan of
tap
, so tests might look not right.