summaryrefslogtreecommitdiff
path: root/src/node_report.cc
diff options
context:
space:
mode:
authorRichard Lau <riclau@uk.ibm.com>2019-03-13 20:39:51 -0400
committerRichard Lau <riclau@uk.ibm.com>2019-03-15 20:48:38 -0400
commitd2681144974c7568524d1d59a25069dc7c9a6294 (patch)
tree167e02bb9a0c1aadcb1be8dcecf63e0f7947b80f /src/node_report.cc
parent969c63a0f1deffaaffcf2bec841bd4a7831559c3 (diff)
downloadandroid-node-v8-d2681144974c7568524d1d59a25069dc7c9a6294.tar.gz
android-node-v8-d2681144974c7568524d1d59a25069dc7c9a6294.tar.bz2
android-node-v8-d2681144974c7568524d1d59a25069dc7c9a6294.zip
report: use DiagnosticFilename for default filename
PR-URL: https://github.com/nodejs/node/pull/26647 Reviewed-By: Colin Ihrig <cjihrig@gmail.com> Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de> Reviewed-By: James M Snell <jasnell@gmail.com> Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com>
Diffstat (limited to 'src/node_report.cc')
-rw-r--r--src/node_report.cc35
1 files changed, 8 insertions, 27 deletions
diff --git a/src/node_report.cc b/src/node_report.cc
index a319f51fdb..2c2616d794 100644
--- a/src/node_report.cc
+++ b/src/node_report.cc
@@ -43,6 +43,7 @@ constexpr double SEC_PER_MICROS = 1e-6;
namespace report {
using node::arraysize;
+using node::DiagnosticFilename;
using node::Environment;
using node::Mutex;
using node::NativeSymbolDebuggingContext;
@@ -92,46 +93,26 @@ std::string TriggerNodeReport(Isolate* isolate,
const char* trigger,
const std::string& name,
Local<String> stackstr) {
- std::ostringstream oss;
std::string filename;
std::shared_ptr<PerIsolateOptions> options;
if (env != nullptr) options = env->isolate_data()->options();
- // Obtain the current time and the pid (platform dependent)
+ // Obtain the current time.
TIME_TYPE tm_struct;
LocalTime(&tm_struct);
// Determine the required report filename. In order of priority:
// 1) supplied on API 2) configured on startup 3) default generated
if (!name.empty()) {
- // Filename was specified as API parameter, use that
- oss << name;
+ // Filename was specified as API parameter.
+ filename = name;
} else if (env != nullptr && options->report_filename.length() > 0) {
- // File name was supplied via start-up option, use that
- oss << options->report_filename;
+ // File name was supplied via start-up option.
+ filename = options->report_filename;
} else {
- // Construct the report filename, with timestamp, pid and sequence number
- oss << "report";
-#ifdef _WIN32
- oss << "." << std::setfill('0') << std::setw(4) << tm_struct.wYear;
- oss << std::setfill('0') << std::setw(2) << tm_struct.wMonth;
- oss << std::setfill('0') << std::setw(2) << tm_struct.wDay;
- oss << "." << std::setfill('0') << std::setw(2) << tm_struct.wHour;
- oss << std::setfill('0') << std::setw(2) << tm_struct.wMinute;
- oss << std::setfill('0') << std::setw(2) << tm_struct.wSecond;
-#else // UNIX, OSX
- oss << "." << std::setfill('0') << std::setw(4) << tm_struct.tm_year + 1900;
- oss << std::setfill('0') << std::setw(2) << tm_struct.tm_mon + 1;
- oss << std::setfill('0') << std::setw(2) << tm_struct.tm_mday;
- oss << "." << std::setfill('0') << std::setw(2) << tm_struct.tm_hour;
- oss << std::setfill('0') << std::setw(2) << tm_struct.tm_min;
- oss << std::setfill('0') << std::setw(2) << tm_struct.tm_sec;
-#endif
- oss << "." << uv_os_getpid();
- oss << "." << std::setfill('0') << std::setw(3) << ++seq;
- oss << ".json";
+ filename = *DiagnosticFilename(env != nullptr ? env->thread_id() : 0,
+ "report", "json", seq++);
}
- filename = oss.str();
// Open the report file stream for writing. Supports stdout/err,
// user-specified or (default) generated name
std::ofstream outfile;