trace_events: respect inspect() depth
This commit causes the Tracing class to account for util.inspect() depth. PR-URL: https://github.com/nodejs/node/pull/28037 Reviewed-By: Anna Henningsen <anna@addaleax.net> Reviewed-By: Luigi Pinca <luigipinca@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This commit is contained in:
parent
39d6da81f9
commit
81a9c7201f
@ -61,6 +61,9 @@ class Tracing {
|
|||||||
}
|
}
|
||||||
|
|
||||||
[customInspectSymbol](depth, opts) {
|
[customInspectSymbol](depth, opts) {
|
||||||
|
if (typeof depth === 'number' && depth < 0)
|
||||||
|
return this;
|
||||||
|
|
||||||
const obj = {
|
const obj = {
|
||||||
enabled: this.enabled,
|
enabled: this.enabled,
|
||||||
categories: this.categories
|
categories: this.categories
|
||||||
|
@ -2519,3 +2519,15 @@ assert.strictEqual(
|
|||||||
assert(i < 2 || line.startsWith('\u001b[90m'));
|
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;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user