| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
Sorry, something went wrong.
|
Review requested:
|
Sorry, something went wrong.
|
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.
|
I now learn this feat in Pino I will try add in node:logger |
Sorry, something went wrong.
|
This will require support for serializers |
Sorry, something went wrong.
I wonder, should we name them like Pino does (built-in serializers), or go with something like standardSerializers ? |
Sorry, something went wrong.
Follow pino and we’ll change it |
Sorry, something went wrong.
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. ➜ 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: 4,868,164.032787085 logger/vs-pino.js scenario="child" logger="node-logger" n=100000: 3,894,327.425314102 logger/vs-pino.js scenario="disabled" logger="node-logger" n=100000: 160,503,080.85663706 logger/vs-pino.js scenario="fields" logger="node-logger" n=100000: 2,157,462.3927336666 logger/vs-pino.js scenario="simple" logger="pino" n=100000: 3,424,706.4418693925 logger/vs-pino.js scenario="child" logger="pino" n=100000: 4,753,595.477010947 logger/vs-pino.js scenario="disabled" logger="pino" n=100000: 122,100,122.10012211 logger/vs-pino.js scenario="fields" logger="pino" n=100000: 1,411,215.99189962 ➜ node git:(mert/create-logger-api/node-core) ✗ |
Sorry, something went wrong.
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) ➜ 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: 6,062,182.962986493 logger/vs-pino.js scenario="child" logger="node-logger" n=100000: 5,758,903.394222795 logger/vs-pino.js scenario="disabled" logger="node-logger" n=100000: 174,026,539.04720467 logger/vs-pino.js scenario="fields" logger="node-logger" n=100000: 2,126,059.37552321 logger/vs-pino.js scenario="simple" logger="pino" n=100000: 3,477,918.037575009 logger/vs-pino.js scenario="child" logger="pino" n=100000: 4,407,389.658686015 logger/vs-pino.js scenario="disabled" logger="pino" n=100000: 145,551,509.22359914 logger/vs-pino.js scenario="fields" logger="pino" n=100000: 1,363,125.197883181 ➜ node git:(mert/create-logger-api/node-core) ✗ |
Sorry, something went wrong.
|
hello @mcollina do you any comments or suggestions for this end commits, I'm curious 🙏 . |
Sorry, something went wrong.
Codecov Report❌ Patch coverage is 95.90044% with 28 lines in your changes missing coverage. Please review.
@@ 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
... and 480 files with indirect coverage changes 🚀 New features to boost your workflow:
|
Sorry, something went wrong.
There was a problem hiding this comment.
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.
| logs independently. | ||
|
|
||
| ```mjs | ||
| import { Logger, JSONConsumer } from 'node:logger'; |
There was a problem hiding this comment.
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.
My understanding is there are quite a few plus in doing node:logger vs node:console/logging. |
Sorry, something went wrong.
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.
Signed-off-by: Mert Can Altin <mertgold60@gmail.com>
|
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.
|
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.
|
I solved the conflict. |
Sorry, something went wrong.
|
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.
| Back | FazBrowse Home | New Git URL |
Description
Adds an experimental node:logger module that provides a structured, high-performance logging API for Node.js. Available behind the --experimental-logger flag.
Refs: #49296
Architecture
API Surface
Log levels follow RFC 5424 numerical ordering internally (trace: 10, debug: 20, info: 30, warn: 40, error: 50, fatal: 60). The API accepts string level names. diagnostics_channel channel names (log:trace, log:debug, log:info, log:warn, log:error, log:fatal) are used internally and can be subscribed to directly via diagnostics_channel if needed.
Performance
Benchmarked against Pino (output to /dev/null, n=100000):
New files
Modified files