diagnostics_channel: capture console messages#56292
Conversation
6ba11e5 to
07fbcd4
Compare
8094626 to
b3830bf
Compare
|
I lack context on this, so I might be missing some point. Can this use the Inspector protocol instead of adding hooks directly into console object. In-process inspector API can be configured to watch for the messages? This way there will be less coupling. |
|
The Inspector API is substantially more expensive. This is meant for being able to rewrite potentially all log messages in production, so it needs to be fast. |
|
Thanks for the reply. |
|
Maybe worth to extend test to verify adding/removing/replacing elements, Main problem I see with mutating diagnostics channels is the undefined sequence if there are more subscribers. |
|
|
||
| * `args` {any\[]} | ||
|
|
||
| Emitted when `console.log()` is called. Receives and array of the arguments |
There was a problem hiding this comment.
Maybe describe that this is the arguments array and therefore mutation is possible.
|
Would you mind rebasing on top of the main branch? The build failure should be fixed once rebased. |
b3830bf to
3548683
Compare
This comment was marked as outdated.
This comment was marked as outdated.
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #56292 +/- ##
=======================================
Coverage 89.19% 89.20%
=======================================
Files 662 662
Lines 191762 191791 +29
Branches 36907 36916 +9
=======================================
+ Hits 171041 171079 +38
+ Misses 13572 13558 -14
- Partials 7149 7154 +5
|
3548683 to
82b3ae5
Compare
|
Test are passing now. I'd appreciate some fresh approvals! 🙂 |
|
Landed in db7a31e |
I've added diagnostics_channel support to capture and modify inputs to the main console methods. This enables some useful things like APMs injecting tracing data into log messages to correlate log messages to the requests from which they originated. You can also replace the args list entirely, so you could apply your own custom formatting to produce JSON logs instead or things like that.
cc @nodejs/diagnostics @nodejs/console