-
Notifications
You must be signed in to change notification settings - Fork 885
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
pino.transport() #1003
pino.transport() #1003
Conversation
I think so. |
Co-authored-by: James Sumners <[email protected]>
Co-authored-by: James Sumners <[email protected]>
This reverts commit ec34df7.
This reverts commit 246b6f0.
Why is that so? I'm not really understanding the need of it. |
I suppose I didn't quite follow what was meant by the item. |
pinole expects a transport to be a pure function: https://github.com/pinojs/pinole/blob/f347c04d4a6c61e05e6ac821e510548aab928458/lib/worker.mjs#L18-L28. You can also see this at https://github.com/pinojs/pino/pull/937/files#diff-b230460830160b31f0c5495a4524feaf9cbc4adba704dbeae6ef3485c45d5b5d |
) | ||
const transport = pino.transport({ | ||
targets: [{ | ||
level: 'info', |
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.
how does this work with custom levels?
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 the level option be supported as a top level option as well?
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.
how does this work with custom levels?
I literally have no clue, I'm not convinced it would work as it is. I would recommend to document that it does not work with custom levels right now.
Co-authored-by: David Mark Clements <[email protected]>
Co-authored-by: David Mark Clements <[email protected]>
@jsumners I think this is ready to go. Could you take a look so we can ship it? |
@mcollina please ping me to revise types after this lands |
@@ -905,6 +906,98 @@ A `pino.destination` instance can also be used to reopen closed files | |||
* See [Reopening log files](/docs/help.md#reopening) | |||
* See [Asynchronous Logging ⇗](/docs/asynchronous.md) | |||
|
|||
<a id="pino-transport"></a> | |||
### `pino.transport(options) => ThreadStream` |
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 should be a callout here, and in the transports specific docs, to notify the reader about CPU core count. Ideally, a core for the main app + a core per worker thread (transport) should be available.
lib/file-target.js
Outdated
const { once } = require('events') | ||
|
||
module.exports = async function (opts) { | ||
// TODO remove the transform |
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.
TODO?
lib/file-target.js
Outdated
} | ||
}) | ||
|
||
// TODO figure out why sync: false does not work here |
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.
TODO?
lib/pretty-target.js
Outdated
// TODO figure out why sync: false does not work here | ||
// TODO remove the istanbul ignore, add a test using a | ||
// child_process |
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.
TODO?
|
||
if (workerOpts.autoEnd !== false) { | ||
// TODO possibly use FinalizationGroup to automatically remove |
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.
TODO?
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 prefer to not resolve this here. There is a space for a tiny little utility for doing exactly this, however it's better developed in isolation. It's more a note for improvements in the future.
This means we are leaking memory if a transport is not closed. I think it's ok.
Co-authored-by: James Sumners <[email protected]>
Co-authored-by: James Sumners <[email protected]>
Co-authored-by: James Sumners <[email protected]>
Co-authored-by: James Sumners <[email protected]>
Co-authored-by: James Sumners <[email protected]>
I've addressed most comments @jsumners |
@kibertoad could you please send a PR to update the types? |
@mcollina I take it api is final and I can add types? |
on it! |
Yes it should be. It might change further in the -rc cycle once we gather feedback, but we are at a point where it's better to give this in the hands of users. |
@mcollina Are you sure that multiple transport example in When I'm trying this:
It explodes on |
good spot: #1049 |
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 add
pino.transport()
based onthread-stream
.In theory, this supersedes #937 as we internalize the pinole part.
Supports Node v12.20.0 onwards.
Things that are missing:
Support for pure function transports (is this actually needed?)