mirror of
https://github.com/nodejs/node.git
synced 2024-11-21 10:59:27 +00:00
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) {
|
||||
if (typeof depth === 'number' && depth < 0)
|
||||
return this;
|
||||
|
||||
const obj = {
|
||||
enabled: this.enabled,
|
||||
categories: this.categories
|
||||
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user