Node.js – process.report 属性
process.report 是一个对象,其方法会生成当前进程的诊断报告。它可在 process 模块中找到。
语法
process.report
示例 1
创建一个名为“report.js”的文件,并复制以下代码段。创建文件后,使用命令“node report.js”运行此代码。
// process.report Demo Example // Importing the process module const process = require('process'); // Getting reports for the below processes const reports = process.report; // Printing out the result console.log(reports)
输出
uC:\home
ode>> node report.js { writeReport: [Function: writeReport], getReport: [Function: getReport], directory: [Getter/Setter], filename: [Getter/Setter], compact: [Getter/Setter], signal: [Getter/Setter], reportOnFatalError: [Getter/Setter], reportOnSignal: [Getter/Setter], reportOnUncaughtException: [Getter/Setter] }
示例 2
我们再来看一个示例。
// process.report Demo Example // Importing the process module const process = require('process'); // Getting reports for the below processes const reports = process.report; // Checking if the report is present if (process.report) { // printing compact Status console.log(process.report.compact) } else { console.log("No data to print compact status") }
输出
No data to print compact status
广告