📜  Node.js process.report 属性

📅  最后修改于: 2022-05-13 01:56:50.979000             🧑  作者: Mango

Node.js process.report 属性

process.report是 process 模块中 Process 类的内置应用程序编程接口,用于提供生成当前进程诊断报告的方法。

句法:

const process.report

返回值:此属性返回生成当前进程诊断报告的方法。

示例 1:

index.js
// Node.js program to demonstrate the  
// Process.report Property
  
// Importing process module
const process = require('process');
  
// Getting reports of the current process
const reports = process.report;
  
// Display the result
console.log(reports)


index.js
// Node.js program to demonstrate the  
// Process.report Property
  
// Importing process module
const process = require('process');
  
// If Report is present
if (process.report) {
   // Printing Report Compact Status
   console.log(process.report.compact)
} else {
   console.log("Unable to print Report Compact Status")
}


使用以下命令运行index.js文件:

node index.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:

index.js

// Node.js program to demonstrate the  
// Process.report Property
  
// Importing process module
const process = require('process');
  
// If Report is present
if (process.report) {
   // Printing Report Compact Status
   console.log(process.report.compact)
} else {
   console.log("Unable to print Report Compact Status")
}

使用以下命令运行index.js文件:

node index.js

输出:

false

参考: https://nodejs.org/dist/latest-v16.x/docs/api/process.html#process_process_report