Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions lib/trace_events.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,9 @@ class Tracing {
}

[customInspectSymbol](depth, opts) {
if (typeof depth === 'number' && depth < 0)
return this;

const obj = {
enabled: this.enabled,
categories: this.categories
Expand Down
12 changes: 12 additions & 0 deletions test/parallel/test-util-inspect.js
Original file line number Diff line number Diff line change
Expand Up @@ -2519,3 +2519,15 @@ assert.strictEqual(
assert(i < 2 || line.startsWith('\u001b[90m'));
});
}

{
// Tracing class respects inspect depth.
try {
const trace = require('trace_events').createTracing({ categories: ['fo'] });
const actual = util.inspect({ trace }, { depth: 0 });
assert.strictEqual(actual, '{ trace: [Tracing] }');
} catch (err) {
if (err.code !== 'ERR_TRACE_EVENTS_UNAVAILABLE')
throw err;
}
}