Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 9dd840d

Browse filesBrowse files
cjihrigBridgeAR
authored andcommitted
trace_events: respect inspect() depth
This commit causes the Tracing class to account for util.inspect() depth. PR-URL: #28037 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
1 parent 2331e9c commit 9dd840d
Copy full SHA for 9dd840d

File tree

Expand file treeCollapse file tree

2 files changed

+15
-0
lines changed
Open diff view settings
Filter options
Expand file treeCollapse file tree

2 files changed

+15
-0
lines changed
Open diff view settings
Collapse file

‎lib/trace_events.js‎

Copy file name to clipboardExpand all lines: lib/trace_events.js
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,9 @@ class Tracing {
6161
}
6262

6363
[customInspectSymbol](depth, opts) {
64+
if (typeof depth === 'number' && depth < 0)
65+
return this;
66+
6467
const obj = {
6568
enabled: this.enabled,
6669
categories: this.categories
Collapse file

‎test/parallel/test-util-inspect.js‎

Copy file name to clipboardExpand all lines: test/parallel/test-util-inspect.js
+12Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2497,3 +2497,15 @@ assert.strictEqual(
24972497
assert(i < 2 || line.startsWith('\u001b[90m'));
24982498
});
24992499
}
2500+
2501+
{
2502+
// Tracing class respects inspect depth.
2503+
try {
2504+
const trace = require('trace_events').createTracing({ categories: ['fo'] });
2505+
const actual = util.inspect({ trace }, { depth: 0 });
2506+
assert.strictEqual(actual, '{ trace: [Tracing] }');
2507+
} catch (err) {
2508+
if (err.code !== 'ERR_TRACE_EVENTS_UNAVAILABLE')
2509+
throw err;
2510+
}
2511+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.