trace_events.getEnabledCategories()
- 返回:<string>
返回所有当前启用的跟踪事件类别的逗号分隔列表。当前启用的跟踪事件类别集合由所有当前启用的 Tracing 对象的_并集_以及使用 --trace-event-categories 标志启用的任何类别决定。
【Returns a comma-separated list of all currently-enabled trace event
categories. The current set of enabled trace event categories is determined
by the union of all currently-enabled Tracing objects and any categories
enabled using the --trace-event-categories flag.】
给定下面的文件 test.js,命令 node --trace-event-categories node.perf test.js 将在控制台打印 'node.async_hooks,node.perf'。
【Given the file test.js below, the command
node --trace-event-categories node.perf test.js will print
'node.async_hooks,node.perf' to the console.】
import { createTracing, getEnabledCategories } from 'node:trace_events';
const t1 = createTracing({ categories: ['node.async_hooks'] });
const t2 = createTracing({ categories: ['node.perf'] });
const t3 = createTracing({ categories: ['v8'] });
t1.enable();
t2.enable();
console.log(getEnabledCategories());const { createTracing, getEnabledCategories } = require('node:trace_events');
const t1 = createTracing({ categories: ['node.async_hooks'] });
const t2 = createTracing({ categories: ['node.perf'] });
const t3 = createTracing({ categories: ['v8'] });
t1.enable();
t2.enable();
console.log(getEnabledCategories());