process.report.writeReport([filename][, err])
-
filename<string> 写入报告的文件的名称。这应该是相对路径,如果未指定,它将附加到process.report.directory中指定的目录或 Node.js 进程的当前工作目录。¥
filename<string> Name of the file where the report is written. This should be a relative path, that will be appended to the directory specified inprocess.report.directory, or the current working directory of the Node.js process, if unspecified. -
err<Error> 用于报告 JavaScript 堆栈的自定义错误。¥
err<Error> A custom error used for reporting the JavaScript stack. -
返回:<string> 返回生成的报告的文件名。
¥Returns: <string> Returns the filename of the generated report.
将诊断报告写入文件。如果未提供 filename,则默认文件名包括日期、时间、PID 和序列号。报告的 JavaScript 堆栈跟踪取自 err(如果存在)。
¥Writes 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.
如果 filename 的值设置为 'stdout' 或 'stderr',则报告分别写入进程的 stdout 或 stderr。
¥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.