Skip to content

Commit 9dd840d

Browse 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 <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]>
1 parent 2331e9c commit 9dd840d

File tree

2 files changed

+15
-0
lines changed

2 files changed

+15
-0
lines changed

‎lib/trace_events.js‎

Lines 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(typeofdepth==='number'&&depth<0)
65+
returnthis;
66+
6467
constobj={
6568
enabled: this.enabled,
6669
categories: this.categories

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

Lines 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+
consttrace=require('trace_events').createTracing({categories: ['fo']});
2505+
constactual=util.inspect({ trace },{depth: 0});
2506+
assert.strictEqual(actual,'{trace: [Tracing] }');
2507+
}catch(err){
2508+
if(err.code!=='ERR_TRACE_EVENTS_UNAVAILABLE')
2509+
throwerr;
2510+
}
2511+
}

0 commit comments

Comments
(0)