-
Notifications
You must be signed in to change notification settings - Fork 897
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
Added onChild
callback with tests and documentation
#1541
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.
Good work! Can you please add a test for the type in https://github.com/pinojs/pino/blob/master/test/types/pino.test-d.ts?
Thanks you! |
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
Thanks again! |
Let's wait a few more reviews, then I'll merge and ship this. |
docs/api.md
Outdated
@@ -508,6 +508,18 @@ when using the `transport` option. In this case an `Error` will be thrown. | |||
|
|||
* See [pino.transport()](#pino-transport) | |||
|
|||
#### `onChild` (Function) | |||
|
|||
The `onChild` function is a callback that will be called on each creation of a new child and use the child instance as it's first argument. |
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.
Does the callback block child creation? Do we handle any errors that occur within the callback?
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.
The callback doesn't block the child creation, unless the it throws an error.
Should we wrap the callback in a try-catch
block?
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.
I think the way the callback is handled should be made clear in the documentation. Adding a try/catch
during child creation will have a performance penalty. So we would want to alter the documentation to make it clear that any error in the callback will be uncaught.
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.
Got it. I've updated the documentation to mention the callback doesn't handle errors.
Co-authored-by: James Sumners <james@sumners.email>
Expanded `onChild` documentation to mention the function doesn't handle errors
@jsumners PTAL |
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.
Looks good to me.
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. |
As discussed in this issue #1534, i've added an
onChild
callback that uses the child instance as its argument.I also included tests and documentation.
Please let me know if anything should be change :)