Open Raynos opened 1 year ago
Hi, Can I work on this
You can work on this, but I must give a disclaimer: this kind of feature will probably involve a lot of "soft" work in terms of achieving consensus both on its necessity and then on the implementation. if you are looking for a smooth entry to this project I would choose an issue with less complexity that also has a consensus about how it should be handled
You can work on this, but I must give a disclaimer: this kind of feature will probably involve a lot of "soft" work in terms of achieving consensus both on its necessity and then on the implementation. if you are looking for a smooth entry to this project I would choose an issue with less complexity that also has a consensus about how it should be handled
yeah sure, please give me an issue with less complexity
There has been no activity on this feature request for 5 months and it is unlikely to be implemented. It will be closed 6 months after the last non-automated comment.
For more information on how the project manages feature requests, please consult the feature request management document.
There has been no activity on this feature request and it is being closed. If you feel closing this issue is not the right thing to do, please leave a comment.
For more information on how the project manages feature requests, please consult the feature request management document.
Reopening ref to https://x.com/vinii_joga10/status/1773674350102659178?s=20
As soon I get some time, I will research how the other langs are handling logs, and I will try to bring some API suggestions on how we can introduce logging at Node.
I think if we create a good abstraction for logging, we can then bring the pino implementation to have some default features, like structured logging
, redact
, and other features.
/cc @mcollina to bring more ideas on this topic since you know a lot about logging & pino.
I will research how the other langs are handling logs
Here's a 2023 article of the official Go blog about this : https://go.dev/blog/slog
I think we could bring 80% of the pino infrastructure down to core. pino is composed of:
It'd need to loose some of the opinions and add some overhead to be more generic, but that can be balanced.
Hey, it took me a long time to start working on research again as I didn't have a good design API in mind around this logging feature. Initially, I tried to create something from scratch, but then I realized that it would be better to rely on a more mature and stable API, like Pino.
So I created a repository to write a wrapper around Pino
that exposes three methods:
setOptions
: To customize the options of the main pin instance.getLogger
: To get a child instance of the main instance (configured via setOptions
).buildTransport
: Basically exposes a way to create new transports for pino.I wrote more details about which properties are exposed and how each method behaves in the repository, so I recommend you take a look at the wrapper implementation, which is quite simple (less than 200 lines).
For me, the main advantage of using pino
is the solid foundation around the transports that Matteo talks more about in this video.
In terms of extensibility, it is very easy to introduce or let users create new transports using buildTransport
, currently the main transport is stdout
but we can expose transports to store the logs in file
, or send via http
and many others.
Please have a look at the repository (link) and tell me what you guys think about this approach, there are a lot of things I don't know yet, like:
undici
or do we want to completely rewrite it?node:logging/transports/file
.Also, to advance this proposal, I created a bunch of issues on the nodejs-logging-proposal repository to try to advance the implementation and have more feedback about each aspect, so feel free to open more issues or add comments to each issue.
I think we should focus on bringing pino in step-by-step. I would also recommend adopting the log levels of https://datatracker.ietf.org/doc/html/rfc5424.
I would remove some of the extreme string mangling.
Imho the steps to bring this to core would:
createWriteStream()
is almost unsuitable for logging purposes due to its lack of synchronous output.console.log
varargs.It's possible to have something using varargs, like the go implementation with alternating arguments for key & value. But we would want to have some form of structured output in a text or json format with key/value pairs.
It's the printf style logging with util.format
that causes unstructured logs that are not parsable or searchable to be generated.
@mcollina This means we are using the foundation of pino but not necessarily bringing pino itself, right? Instead of doing like undici
, we will have a fork that is less opinionated?
maybe core of pino could be extracted, and then used by pino itself?..
@kibertoad I think more of redo without the cruft accumulated in 8 years + fixing some old warts from the Crankshaftscript era.
There has been no activity on this feature request for 5 months. To help maintain relevant open issues, please add the https://github.com/nodejs/node/labels/never-stale label or close this issue if it should be closed. If not, the issue will be automatically closed 6 months after the last non-automated comment. For more information on how the project manages feature requests, please consult the feature request management document.
What is the problem this feature will solve?
To have a structured log package available in stdlib so that all npm modules can log in a single fashion instead of
What is the feature you are proposing to solve the problem?
Implement something like https://go.dev/blog/slog
What alternatives have you considered?
No response