lib: added logger api in node core#60468
Conversation
|
Review requested:
|
|
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 |
|
I now learn this feat in Pino I will try add in node:logger |
|
This will require support for serializers |
I wonder, should we name them like Pino does (built-in serializers), or go with something like standardSerializers ? |
Follow pino and we’ll change it |
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. |
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) |
|
hello @mcollina do you any comments or suggestions for this end commits, I'm curious 🙏 . |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #60468 +/- ##
==========================================
- Coverage 89.74% 89.70% -0.04%
==========================================
Files 674 678 +4
Lines 204395 206665 +2270
Branches 39274 39565 +291
==========================================
+ Hits 183427 185399 +1972
- Misses 13275 13420 +145
- Partials 7693 7846 +153
🚀 New features to boost your workflow:
|
f5b0108 to
429359b
Compare
Co-authored-by: Rafael Gonzaga <rafael.nunu@hotmail.com>
|
@AugustinMauroy @RafaelGSS Thanks for the review, edited your comments |
|
@RafaelGSS please take a look. 7 days passed since your review has been requested. |
| @@ -0,0 +1,819 @@ | |||
| # Logger | |||
|
|
|||
| <!--introduced_in=v26.0.0--> | |||
There was a problem hiding this comment.
Unless we flag this as semver-major, this is wrong.
| <!-- source_link=lib/logger.js --> | ||
|
|
||
| The `node:logger` module provides high-performance structured logging |
There was a problem hiding this comment.
We should clarify this is only enabled via --experimental-logger
| * `obj` {Object} Object containing `msg` property and additional fields. | ||
| * `error` {Error} Error object to log. | ||
| * `fields` {Object} Additional fields to include in the log record. |
There was a problem hiding this comment.
It's not clear its impact on the call
| * `msg` {string} Log message. | ||
| * `obj` {Object} Object containing `msg` property and additional fields. | ||
| * `error` {Error} Error object to log. | ||
| * `fields` {Object} Additional fields to include in the log record. |
| logger.fatal(new Error('Unrecoverable error')); | ||
| ``` | ||
|
|
||
| ### `logger.child(bindings[, options])` |
There was a problem hiding this comment.
Considering child logger instances are a bit complex, I'd also include it as > stability 1.1
| */ | ||
| function serializeErr(error) { | ||
| if (!isNativeError(error)) { | ||
| return error; |
There was a problem hiding this comment.
It's not clear to me why we return if it's not a native error; shouldn't we log/fail instead?
| // Handle error cause recursively | ||
| if (error.cause !== undefined) { | ||
| obj.cause = typeof error.cause === 'object' && error.cause !== null ? | ||
| serializeErr(error.cause) : |
There was a problem hiding this comment.
Couldn't it cause a crash if it recurses indefinitely?
| // Create channels for each log level | ||
| const channels = { | ||
| __proto__: null, | ||
| trace: diagnosticsChannel.channel('log:trace'), |
There was a problem hiding this comment.
we should document the channel names used somewhere.
It's a 2.5k lines PR, it's hard to concilate time to review it properly. |
Co-authored-by: Rafael Gonzaga <rafael.nunu@hotmail.com>
Co-authored-by: Rafael Gonzaga <rafael.nunu@hotmail.com>
for: #49296 (comment)
I try a draft development for new logger api, and i try create some benchmark for pino and node:logger package