GeezerVisonThe World Wide Web, restored to 800 pixels of glory. | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Home|About|Gaming cabinet|Archives|How it works|Starter sites | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
GeezerVison is showing github.com — lib: added logger api to node core by mertcanaltin · Pull Request #60468 · nodejs/node Conversation
|
| Scenario | node:logger | pino | Difference |
|---|---|---|---|
| simple | 6.06M ops/s | 3.48M ops/s | +74% |
| child | 5.76M ops/s | 4.41M ops/s | +31% |
| disabled | 174M ops/s | 146M ops/s | +19% |
| fields | 2.13M ops/s | 1.36M ops/s | +56% |
lib/logger.js, Main module (Logger, LogConsumer, JSONConsumer)lib/internal/logger/serializers.js, Standard err/req/res serializersdoc/api/logger.md, Full API documentationbenchmark/logger/basic-json.js, Benchmarkstest/parallel/test-log-basic.js, Core logger teststest/parallel/test-logger-serializers.js, Serializer testssrc/node_options.h / src/node_options.cc, --experimental-logger flaglib/internal/process/pre_execution.js, setupLogger() to allow module loading when flag is setlib/internal/bootstrap/realm.js, Module registrationdoc/api/cli.md, Flag documentationdoc/api/index.md / doc/node.1, Index updatestest/parallel/test-code-cache.js / test-process-get-builtin.mjs / test-require-resolve.js, Test adjustments for new module
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Review requested:
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
thats my first performance results: I think need improvement for child logger area, but ı'm so happy because other results it looks nice. node:logger vs pino ➜ node git:(mert/create-logger-api/node-core) ✗ ./node benchmark/logger/vs-pino.js n=100000 logger/vs-pino.js scenario="simple" logger="node-logger" n=100000: 5,240,540.823813018 logger/vs-pino.js scenario="child" logger="node-logger" n=100000: 2,635,847.7027229806 logger/vs-pino.js scenario="disabled" logger="node-logger" n=100000: 159,436,487.67795104 logger/vs-pino.js scenario="fields" logger="node-logger" n=100000: 3,619,336.304205216 logger/vs-pino.js scenario="simple" logger="pino" n=100000: 3,398,489.9761368227 logger/vs-pino.js scenario="child" logger="pino" n=100000: 4,489,799.803418606 logger/vs-pino.js scenario="disabled" logger="pino" n=100000: 119,772,384.56038144 logger/vs-pino.js scenario="fields" logger="pino" n=100000: 1,257,930.8609750536 |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
I now learn this feat in Pino I will try add in node:logger |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
This will require support for serializers |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
I wonder, should we name them like Pino does (built-in serializers), or go with something like standardSerializers ? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Follow pino and we’ll change it |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
I tryed serializer implement for logger, and some bench result repaired and fields and simple are experiencing a decline; I will try to resolve these fields: 3.62M → 2.16M (-40%) previously, the results for the child logger were quite slow at around 70%, but the new results have dropped to 18% and have actually improved significantly. I continue to try new methods. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
I inspected pino and I learn some patterns, than I applied this commit and new results! 1ededc7 I used this patterns removed the cost of serializing bindings in each log for the child logger, simple: 6.06M vs 3.48M ops/s (+74% faster) |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
hello @mcollina do you any comments or suggestions for this end commits, I'm curious 🙏 . |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@ ## main #60468 +/- ## ========================================== - Coverage 92.07% 90.33% -1.74% ========================================== Files 399 753 +354 Lines 177007 250459 +73452 Branches 27381 47293 +19912 ========================================== + Hits 162978 226255 +63277 - Misses 13716 15567 +1851 - Partials 313 8637 +8324
🚀 New features to boost your workflow:
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
f5b0108 to
429359b
Compare
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
I have a few issues with this implementation, which probably would need a bit more design and community discussion before landing.
The main problem with this is that the diagnostic channels are global. This match reality for most applications I've seen where logging is a "global" concern, however it makes it harder for testing. We create a logger with new, which implies a local scope, even though the logs go to a global stream.
Let's say that I what to create two or more instances of the logger with two different transports, how can I achieve that?
(I still think that diagnostics_channel are the best primitive here, but we need to have answers to these questions?
In most implementations, log levels are actually mapped to integers. This has an advantage when further processing them down. We can see this in action with the n number of diagnostic channel listeners. This is present here, but not moved down the diagnostics channels. Why do we have one channel per level instead of just a single channel with integer values?
The concept of "ERROR is more important than INFO" is pushed down to consumers, and not built into the lib.
As an additional question: many companies want to create their own custom levels (unfortunately), how can this be implemented here?
Note this is about tradeoffs.
Part of the goal of this library is to be protocol agnostic, however there is a #bindingStr, which is some inheritance from Pino. I don't think we can afford to do this here in a generic way.
Child logger properties should be LRUd/cached down in the consumer.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
| logs independently. | ||
|
|
||
| ```mjs | ||
| import { Logger, JSONConsumer } from 'node:logger'; |
There was a problem hiding this comment.
The reason will be displayed to describe this comment to others. Learn more.
Adding a new module should be a minor change
IMHO this was due to the "shadowing" of the ecosystem. I think this is relaxable/not needed for node: prefixed modules.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
My understanding is there are quite a few plus in doing |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
right, unfortunately current desing is acting wrongly, I tried create new consumer but hit the some global key "log:info"
yes not protocol agnostic current code, if as you said this different consumer, example msgpack or send to opentelemetry the current record only carries a JSON string, so a non-JSON consumer can't use it but if I use protocol-agnostic, it work for all consumer, but without cache it serialize every log, so million times I think good weakMap for this problem, fast and protocol agnostic
sgtm, as you said, the level is already in the record, so we can use a single channel and send the integer level in the payload, since the level is just a number, custom levels become easy, without the lib knowing it in advence |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Signed-off-by: Mert Can Altin <[email protected]>
|
Hello @mcollina, I sent a repair commit for your comments, now we use a single diagnostics channel, bindings cache as you said moved to consumer, removed before serialized bindingsStr , now has a numeric level for all record |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I want to get your comments on custom levels each record already has levelValue, so no core changes needed to add them later |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Hi @mcollina, I've addressed your review comments in 2e64414. The logger now publishes to a single log channel, and consumers filter by level on their side. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I solved the conflict. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
To avoid taking up any more of the reviewers time, I'm closing this PR. Thanks a lot, everyone. If anyone wants to pick this up and needs help, I'd be happy to assist them. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
Successfully merging this pull request may close these issues.
There was an error while loading. Please reload this page.