process.report
History
Objectprocess.report is an object whose methods are used to generate diagnostic
reports for the current process. Additional documentation is available in the
report documentation.
booleanWrite reports in a compact format, single-line JSON, more easily consumable by log processing systems than the default multi-line format designed for human consumption.
import { report } from 'node:process'; console.log(`Reports are compact? ${report.compact}`);
const { report } = require('node:process'); console.log(`Reports are compact? ${report.compact}`);
process.report.directory
History
stringDirectory where the report is written. The default value is the empty string, indicating that reports are written to the current working directory of the Node.js process.
import { report } from 'node:process'; console.log(`Report directory is ${report.directory}`);
const { report } = require('node:process'); console.log(`Report directory is ${report.directory}`);
process.report.filename
History
stringFilename where the report is written. If set to the empty string, the output filename will be comprised of a timestamp, PID, and sequence number. The default value is the empty string.
If the value of process.report.filename is set to 'stdout' or 'stderr',
the report is written to the stdout or stderr of the process respectively.
import { report } from 'node:process'; console.log(`Report filename is ${report.filename}`);
const { report } = require('node:process'); console.log(`Report filename is ${report.filename}`);
process.report.getReport
History
process.report.getReport(err?): Object
Returns a JavaScript Object representation of a diagnostic report for the
running process. The report's JavaScript stack trace is taken from err, if
present.
import { report } from 'node:process'; import util from 'node:util'; const data = report.getReport(); console.log(data.header.nodejsVersion); // Similar to process.report.writeReport() import fs from 'node:fs'; fs.writeFileSync('my-report.log', util.inspect(data), 'utf8');
const { report } = require('node:process'); const util = require('node:util'); const data = report.getReport(); console.log(data.header.nodejsVersion); // Similar to process.report.writeReport() const fs = require('node:fs'); fs.writeFileSync('my-report.log', util.inspect(data), 'utf8');
Additional documentation is available in the report documentation.
process.report.reportOnFatalError
History
booleanIf true, a diagnostic report is generated on fatal errors, such as out of
memory errors or failed C++ assertions.
import { report } from 'node:process'; console.log(`Report on fatal error: ${report.reportOnFatalError}`);
const { report } = require('node:process'); console.log(`Report on fatal error: ${report.reportOnFatalError}`);
process.report.reportOnSignal
History
booleanIf true, a diagnostic report is generated when the process receives the
signal specified by process.report.signal.
import { report } from 'node:process'; console.log(`Report on signal: ${report.reportOnSignal}`);
const { report } = require('node:process'); console.log(`Report on signal: ${report.reportOnSignal}`);
process.report.reportOnUncaughtException
History
booleanIf true, a diagnostic report is generated on uncaught exception.
import { report } from 'node:process'; console.log(`Report on exception: ${report.reportOnUncaughtException}`);
const { report } = require('node:process'); console.log(`Report on exception: ${report.reportOnUncaughtException}`);
booleanIf true, a diagnostic report is generated without the environment variables.
process.report.signal
History
stringThe signal used to trigger the creation of a diagnostic report. Defaults to
'SIGUSR2'.
import { report } from 'node:process'; console.log(`Report signal: ${report.signal}`);
const { report } = require('node:process'); console.log(`Report signal: ${report.signal}`);
process.report.writeReport
History
process.report.writeReport(filename?, err?): string
stringprocess.report.directory, or the current working directory of the Node.js
process, if unspecified.ErrorstringWrites a diagnostic report to a file. If filename is not provided, the default
filename includes the date, time, PID, and a sequence number. The report's
JavaScript stack trace is taken from err, if present.
If the value of filename is set to 'stdout' or 'stderr', the report is
written to the stdout or stderr of the process respectively.
import { report } from 'node:process'; report.writeReport();
const { report } = require('node:process'); report.writeReport();
Additional documentation is available in the report documentation.