report: rename triggerReport() to writeReport()
writeReport() is more descriptive of what the function does. PR-URL: https://github.com/nodejs/node/pull/26527 Reviewed-By: Richard Lau <riclau@uk.ibm.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
This commit is contained in:
parent
d73d861665
commit
806d3d71e2
@ -1772,7 +1772,7 @@ The signal used to trigger the creation of a diagnostic report. Defaults to
|
||||
console.log(`Report signal: ${process.report.signal}`);
|
||||
```
|
||||
|
||||
### process.report.triggerReport([filename][, err])
|
||||
### process.report.writeReport([filename][, err])
|
||||
<!-- YAML
|
||||
added: v11.8.0
|
||||
-->
|
||||
@ -1790,7 +1790,7 @@ filename includes the date, time, PID, and a sequence number. The report's
|
||||
JavaScript stack trace is taken from `err`, if present.
|
||||
|
||||
```js
|
||||
process.report.triggerReport();
|
||||
process.report.writeReport();
|
||||
```
|
||||
|
||||
Additional documentation is available in the [report documentation][].
|
||||
|
@ -404,14 +404,14 @@ written.
|
||||
A report can also be triggered via an API call from a JavaScript application:
|
||||
|
||||
```js
|
||||
process.report.triggerReport();
|
||||
process.report.writeReport();
|
||||
```
|
||||
|
||||
This function takes an optional additional argument `filename`, which is
|
||||
the name of a file into which the report is written.
|
||||
|
||||
```js
|
||||
process.report.triggerReport('./foo.json');
|
||||
process.report.writeReport('./foo.json');
|
||||
```
|
||||
|
||||
This function takes an optional additional argument `err` - an `Error` object
|
||||
@ -424,19 +424,19 @@ as where it was handled.
|
||||
try {
|
||||
process.chdir('/non-existent-path');
|
||||
} catch (err) {
|
||||
process.report.triggerReport(err);
|
||||
process.report.writeReport(err);
|
||||
}
|
||||
// Any other code
|
||||
```
|
||||
|
||||
If both filename and error object are passed to `triggerReport()` the
|
||||
If both filename and error object are passed to `writeReport()` the
|
||||
error object must be the second parameter.
|
||||
|
||||
```js
|
||||
try {
|
||||
process.chdir('/non-existent-path');
|
||||
} catch (err) {
|
||||
process.report.triggerReport(filename, err);
|
||||
process.report.writeReport(filename, err);
|
||||
}
|
||||
// Any other code
|
||||
```
|
||||
@ -470,7 +470,7 @@ triggered using the Node.js REPL:
|
||||
|
||||
```raw
|
||||
$ node
|
||||
> process.report.triggerReport();
|
||||
> process.report.writeReport();
|
||||
Writing Node.js report to file: report.20181126.091102.8480.001.json
|
||||
Node.js report completed
|
||||
>
|
||||
|
@ -110,7 +110,7 @@ function createFatalException() {
|
||||
try {
|
||||
const report = internalBinding('report');
|
||||
if (report != null && report.shouldReportOnUncaughtException()) {
|
||||
report.triggerReport(er ? er.message : 'Exception',
|
||||
report.writeReport(er ? er.message : 'Exception',
|
||||
'Exception',
|
||||
null,
|
||||
er ? er.stack : undefined);
|
||||
|
@ -7,7 +7,7 @@ const {
|
||||
const { validateString } = require('internal/validators');
|
||||
const nr = internalBinding('report');
|
||||
const report = {
|
||||
triggerReport(file, err) {
|
||||
writeReport(file, err) {
|
||||
if (typeof file === 'object' && file !== null) {
|
||||
err = file;
|
||||
file = undefined;
|
||||
@ -19,7 +19,7 @@ const report = {
|
||||
throw new ERR_INVALID_ARG_TYPE('err', 'Object', err);
|
||||
}
|
||||
|
||||
return nr.triggerReport('JavaScript API', 'API', file, err.stack);
|
||||
return nr.writeReport('JavaScript API', 'API', file, err.stack);
|
||||
},
|
||||
getReport(err) {
|
||||
if (err === undefined)
|
||||
@ -101,7 +101,7 @@ function removeSignalHandler() {
|
||||
}
|
||||
|
||||
function signalHandler(sig) {
|
||||
nr.triggerReport(sig, 'Signal', null, '');
|
||||
nr.writeReport(sig, 'Signal', null, '');
|
||||
}
|
||||
|
||||
module.exports = {
|
||||
|
@ -67,7 +67,7 @@ std::string ValueToHexString(T value) {
|
||||
}
|
||||
|
||||
// Function declarations - export functions in src/node_report_module.cc
|
||||
void TriggerReport(const v8::FunctionCallbackInfo<v8::Value>& info);
|
||||
void WriteReport(const v8::FunctionCallbackInfo<v8::Value>& info);
|
||||
void GetReport(const v8::FunctionCallbackInfo<v8::Value>& info);
|
||||
|
||||
// Node.js boot time - defined in src/node.cc
|
||||
|
@ -30,8 +30,7 @@ using v8::Object;
|
||||
using v8::String;
|
||||
using v8::Value;
|
||||
|
||||
// External JavaScript API for triggering a report
|
||||
void TriggerReport(const FunctionCallbackInfo<Value>& info) {
|
||||
void WriteReport(const FunctionCallbackInfo<Value>& info) {
|
||||
Environment* env = Environment::GetCurrent(info);
|
||||
Isolate* isolate = env->isolate();
|
||||
HandleScope scope(isolate);
|
||||
@ -161,7 +160,7 @@ static void Initialize(Local<Object> exports,
|
||||
Local<Context> context) {
|
||||
Environment* env = Environment::GetCurrent(context);
|
||||
|
||||
env->SetMethod(exports, "triggerReport", TriggerReport);
|
||||
env->SetMethod(exports, "writeReport", WriteReport);
|
||||
env->SetMethod(exports, "getReport", GetReport);
|
||||
env->SetMethod(exports, "getDirectory", GetDirectory);
|
||||
env->SetMethod(exports, "setDirectory", SetDirectory);
|
||||
|
@ -27,19 +27,19 @@ function validate() {
|
||||
|
||||
{
|
||||
// Test with no arguments.
|
||||
process.report.triggerReport();
|
||||
process.report.writeReport();
|
||||
validate();
|
||||
}
|
||||
|
||||
{
|
||||
// Test with an error argument.
|
||||
process.report.triggerReport(new Error('test error'));
|
||||
process.report.writeReport(new Error('test error'));
|
||||
validate();
|
||||
}
|
||||
|
||||
{
|
||||
// Test with a file argument.
|
||||
const file = process.report.triggerReport('custom-name-1.json');
|
||||
const file = process.report.writeReport('custom-name-1.json');
|
||||
const absolutePath = path.join(tmpdir.path, file);
|
||||
assert.strictEqual(helper.findReports(process.pid, tmpdir.path).length, 0);
|
||||
assert.strictEqual(file, 'custom-name-1.json');
|
||||
@ -49,7 +49,7 @@ function validate() {
|
||||
|
||||
{
|
||||
// Test with file and error arguments.
|
||||
const file = process.report.triggerReport('custom-name-2.json',
|
||||
const file = process.report.writeReport('custom-name-2.json',
|
||||
new Error('test error'));
|
||||
const absolutePath = path.join(tmpdir.path, file);
|
||||
assert.strictEqual(helper.findReports(process.pid, tmpdir.path).length, 0);
|
||||
@ -61,7 +61,7 @@ function validate() {
|
||||
{
|
||||
// Test with a filename option.
|
||||
process.report.filename = 'custom-name-3.json';
|
||||
const file = process.report.triggerReport();
|
||||
const file = process.report.writeReport();
|
||||
assert.strictEqual(helper.findReports(process.pid, tmpdir.path).length, 0);
|
||||
const filename = path.join(process.report.directory, 'custom-name-3.json');
|
||||
assert.strictEqual(file, process.report.filename);
|
||||
@ -72,21 +72,21 @@ function validate() {
|
||||
// Test with an invalid file argument.
|
||||
[null, 1, Symbol(), function() {}].forEach((file) => {
|
||||
common.expectsError(() => {
|
||||
process.report.triggerReport(file);
|
||||
process.report.writeReport(file);
|
||||
}, { code: 'ERR_INVALID_ARG_TYPE' });
|
||||
});
|
||||
|
||||
// Test with an invalid error argument.
|
||||
[null, 1, Symbol(), function() {}, 'foo'].forEach((error) => {
|
||||
common.expectsError(() => {
|
||||
process.report.triggerReport('file', error);
|
||||
process.report.writeReport('file', error);
|
||||
}, { code: 'ERR_INVALID_ARG_TYPE' });
|
||||
});
|
||||
|
||||
{
|
||||
// Test the special "stdout" filename.
|
||||
const args = ['--experimental-report', '-e',
|
||||
'process.report.triggerReport("stdout")'];
|
||||
'process.report.writeReport("stdout")'];
|
||||
const child = spawnSync(process.execPath, args, { cwd: tmpdir.path });
|
||||
assert.strictEqual(child.status, 0);
|
||||
assert.strictEqual(child.signal, null);
|
||||
@ -97,7 +97,7 @@ function validate() {
|
||||
{
|
||||
// Test the special "stderr" filename.
|
||||
const args = ['--experimental-report', '-e',
|
||||
'process.report.triggerReport("stderr")'];
|
||||
'process.report.writeReport("stderr")'];
|
||||
const child = spawnSync(process.execPath, args, { cwd: tmpdir.path });
|
||||
assert.strictEqual(child.status, 0);
|
||||
assert.strictEqual(child.signal, null);
|
||||
@ -113,7 +113,7 @@ function validate() {
|
||||
const args = ['--experimental-report',
|
||||
`--diagnostic-report-directory=${reportDir}`,
|
||||
'-e',
|
||||
'process.report.triggerReport()'];
|
||||
'process.report.writeReport()'];
|
||||
const child = spawnSync(process.execPath, args, { cwd: tmpdir.path });
|
||||
|
||||
assert.strictEqual(child.status, 0);
|
Loading…
x
Reference in New Issue
Block a user