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: implement node:logger by jasnell · Pull Request #65840 · nodejs/node Conversation
|
|
Review requested:
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@mertcanaltin, your experience from #60468 may be valuable here. |
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 #65840 +/- ## ========================================== + Coverage 90.17% 90.68% +0.51% ========================================== Files 771 772 +1 Lines 265097 269087 +3990 Branches 50362 55919 +5557 ========================================== + Hits 239054 244028 +4974 + Misses 17004 16077 -927 + Partials 9039 8982 -57
🚀 New features to boost your workflow:
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
I think this step is very good for review. We started with a big step before, but it was very costly for reviewers. I want to share some topics we had in #60468. I hope they help this PR. Do custom levels need to be part of the public contract in the first version? I'm not sure. Level names and numeric ordering are a long-term cost for both users and providers. My suggestion is to limit the first version to the built-in levels, so the API stays smaller. Providers can do their own mapping internally when necessary. This comment is not a blocker for this PR. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
I think they ought to be, yes, at least to an extent. I absolutely don't think we should do the automatic custom level method installation like what pino does (e.g. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
1a8be55 to
b1e0970
Compare
There was an error while loading. Please reload this page.
10db06e to
efff647
Compare
|
As a pure curiosity, how does the performance of this compare with the approach that was being followed in #60468? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
It appears that all logger attempts failed even though they do provide useful value. Unfortunate. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Are those objections publicly available anywhere? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
No. I will consider re-opening this if there is enough contributor / ecosystem interest expressed. But I don't feel like fighting Yet Another "Small Core" battle. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
It feels like the TSC has gotten worse at working in public. In this particular case, nothing needs to be private, and folks without access to the private TSC channels never even got a chance to engage in those conversations. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
As I said, if there's enough expressed interest here, I'll re-open. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
@jasnell What's the best way to express interest? comments? emojis? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Just use emoji reactions for simple expression. Save discussion for substantive comments. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
What qualifies as enough interest? |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
Enough that I can make the argument that the ecosystem would consider adding the new top-level-module-that-could-also-probably-just-be-implemented-as-an-npm-module valuable enough to add. It's the typical small core argument with added concern about the current volume of activity due to AI-assisted contributions vs differing opinions about what improves developer experience. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
I personally really like it. The reason I think this should be in core, is because it would allow modules to use a shared logging facade. in userspace, there will never be „the way to log“ across different authors and package. Having a shared facade allows all module authors to utilize the share facade without predetermining the actual logging destination. Enabling cross module and cross author logging will almost certainly create for better issue discovery in the long run. The way this leaves the actual logging backend to userspace seems to be the right split to me as it gives us the best of both worlds: a shared facade and full customisation of the destination. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
|
This may be a wrong approach, but is there anything that could be ported to native from this? Perhaps an argument could form around the more complex nature of the implementation, which is not "just a JS module" anymore. This besides the potential performance improvements that can not be achieved through pure JS. |
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's really nothing to port to native and no justification why we would unless it could be clearly demonstrated to have massive perf advantages, which I'd be surprised. What this PR adds is largely a logging facade / coordinator. The providers themselves do the actual work and those can be implemented in many different ways. Tell you what.. rather than closing this, let me re-open and move it to draft while we work through the details. |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
8c90477 to
9cab94c
Compare
9cab94c to
bee5d56
Compare
71d82d2 to
cc8dc7c
Compare
There was an error while loading. Please reload this page.
|
@mcollina ... some updates here around perf improvements... here's where it stands vs. pino (note, AI generated report). It's worth taking a very critical view of the changes. Performance comparison:
|
| Scenario | node:logger | pino | Ratio | Result |
|---|---|---|---|---|
Disabled info() |
0.33 ns | 0.33 ns | 0.98 | About equal |
| Disabled, with attributes | 0.51 ns | 0.46 ns | 0.89 | About equal (borderline noise) |
| Enabled, message only | 123 ns | 123 ns | 1.00 | About equal |
| Enabled, with attributes | 375 ns | 376 ns | 1.00 | About equal |
Enabled, Error attribute |
642 ns | 1126 ns | 1.75 | node:logger faster |
child() creation |
72 ns | 89 ns | 1.23 | node:logger faster |
| Logging through a reused child | 244 ns | 219 ns | 0.89 | pino 1.12× faster |
| New child per request + 3 lines | 919 ns | 681 ns | 0.74 | pino 1.35× faster |
| Scenario | node:logger | pino | Ratio |
|---|---|---|---|
| Async, yielding, message only | 248 ns | 732 ns | 2.95 |
| Async, yielding, with attributes | 505 ns | 1143 ns | 2.26 |
| Sync, yielding, message only | 1012 ns | 1359 ns | 1.34 |
| Sync, yielding, with attributes | 1245 ns | 1650 ns | 1.33 |
| Async, no yield, message only | 609 ns | 1000 ns | 1.64 |
| Async, no yield, with attributes | 1087 ns | 1305 ns | 1.20 |
| Sync, no yield, message only | 964 ns | 1346 ns | 1.40 |
| Sync, no yield, with attributes | 1229 ns | 1665 ns | 1.35 |
| Scenario | Initial | Serializer fast path | Errors & strings | Cheaper child construction | Composed bindings | Small wins | Deferred child setup |
|---|---|---|---|---|---|---|---|
| Enabled, message only | 772 | 252 | 168 | 156 | – | 130 | 123 |
| Enabled, with attributes | 1153 | 609 | 395 | – | – | 350 | 375 |
Enabled, Error attribute |
1633 | 1735 | 686 | – | – | – | 642 |
child() creation |
390 | 358 | 299 | 143 | 153 | – | 72 |
| Logging through a reused child | 1122 | 426 | 284 | 283 | 284 | 246 | 244 |
| New child + 3 lines | – | – | – | 1264 | 1023 | 1025 | 919 |
Date.now(), number-to-string conversion, key-cache lookups). No single dominant cost remains.write() syscall per line for both loggers. The minLength option is the existing way to batch writes.
Sorry, something went wrong.
There was an error while loading. Please reload this page.
There was an error while loading. Please reload this page.
|
Per the discussion at the collaborator summit.. the plan on this is to move TODOs
|
Sorry, something went wrong.
There was an error while loading. Please reload this page.
Keep scheme-only and option-gated builtin exposure rules in the JavaScript loader. Leave option registration and code-cache categorization with their native owners. Assisted-by: Codex Signed-off-by: sjungwon03 <[email protected]> PR-URL: #66292 Refs: #65418 Refs: #65964 Refs: #65920 Refs: #65840 Reviewed-By: Daeyeon Jeong <[email protected]>
Fix several issues with `Utf8Stream` flushing: * `flush()` now writes buffered data regardless of `minLength` and invokes the callback only after pending writes complete, including when `minLength` is zero and a write is in flight. * Multiple concurrent `flush()` calls are tracked correctly and `end()` waits for pending flushes before closing. * `flushSync()` throws `ERR_INVALID_STATE` if called while an asynchronous write is in progress instead of corrupting output. * Periodic flushes no longer stack up while a flush is pending. * `fsync` is skipped for stdout/stderr file descriptors. * `reopen()`, `end()` and `destroy()` behave correctly when the stream is destroyed while still opening. Signed-off-by: James M Snell <[email protected]> Assisted-by: Opencode
A simpler attempt to add a structured logging API.
Uses a provider model similar to VFS.
This implements two providers out of the box,
ConsoleProvider and ReadableProvider. ConsoleProvider
is the default and uses Utf8Stream to emit to either
stdout or stderr.
```js
const { create } = require('node:logger');
const logger = create(); // default logger to console
logger.info('foo');
// ...
const als = new AsyncLocalStorage();
const logger2 = create(new ConsoleProvider({ pid: true }), {
name: 'foo',
bindings: {
'abc': 'included in every log line',
'xyz': als, // current als.getStore() included in
// every log line
}
});
logger2.info('foo', { baz: 1 });
```
The `Logger` keeps things as simple as possible, leaving
actual handling of the log events to the providers, which
can be fully customized. Easy to adapt to other loggers
like pino or extend capabilities without directly touching
the facade.
Signed-off-by: James M Snell <[email protected]>
Assisted-by: Opencode
cc8dc7c to
59cfdd3
Compare
Keep scheme-only and option-gated builtin exposure rules in the JavaScript loader. Leave option registration and code-cache categorization with their native owners. Assisted-by: Codex Signed-off-by: sjungwon03 <[email protected]> PR-URL: #66292 Refs: #65418 Refs: #65964 Refs: #65920 Refs: #65840 Reviewed-By: Daeyeon Jeong <[email protected]>
Keep scheme-only and option-gated builtin exposure rules in the JavaScript loader. Leave option registration and code-cache categorization with their native owners. Assisted-by: Codex Signed-off-by: sjungwon03 <[email protected]> PR-URL: #66292 Refs: #65418 Refs: #65964 Refs: #65920 Refs: #65840 Reviewed-By: Daeyeon Jeong <[email protected]>
|
Echoing the commentary I brought up during the collab summit so it doesn't get lost: Opting-in to DC via In addition, an injection operation ought to be possible, and be possible to happen transparently. For example, the logged object could be modified in a |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
So are further under-node-org but published separately modules likely to happen more in future for extremely commonly used things? And if so, will maintenance and stability index follow that of node? Or is there a risk that if This is something that I always thought Deno had the right idea with their std libraries, so that people don't have to deal with churn with |
Sorry, something went wrong.
There was an error while loading. Please reload this page.
At least 1 approving review is required to merge this pull request.
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.