@@ -43,6 +43,7 @@ constexpr double SEC_PER_MICROS = 1e-6;
43
43
44
44
namespace report {
45
45
using node::arraysize;
46
+ using node::DiagnosticFilename;
46
47
using node::Environment;
47
48
using node::Mutex;
48
49
using node::NativeSymbolDebuggingContext;
@@ -92,46 +93,26 @@ std::string TriggerNodeReport(Isolate* isolate,
92
93
const char * trigger,
93
94
const std::string& name,
94
95
Local<String> stackstr) {
95
- std::ostringstream oss;
96
96
std::string filename;
97
97
std::shared_ptr<PerIsolateOptions> options;
98
98
if (env != nullptr ) options = env->isolate_data ()->options ();
99
99
100
- // Obtain the current time and the pid (platform dependent)
100
+ // Obtain the current time.
101
101
TIME_TYPE tm_struct;
102
102
LocalTime (&tm_struct);
103
103
// Determine the required report filename. In order of priority:
104
104
// 1) supplied on API 2) configured on startup 3) default generated
105
105
if (!name.empty ()) {
106
- // Filename was specified as API parameter, use that
107
- oss << name;
106
+ // Filename was specified as API parameter.
107
+ filename = name;
108
108
} else if (env != nullptr && options->report_filename .length () > 0 ) {
109
- // File name was supplied via start-up option, use that
110
- oss << options->report_filename ;
109
+ // File name was supplied via start-up option.
110
+ filename = options->report_filename ;
111
111
} else {
112
- // Construct the report filename, with timestamp, pid and sequence number
113
- oss << " report" ;
114
- #ifdef _WIN32
115
- oss << " ." << std::setfill (' 0' ) << std::setw (4 ) << tm_struct.wYear ;
116
- oss << std::setfill (' 0' ) << std::setw (2 ) << tm_struct.wMonth ;
117
- oss << std::setfill (' 0' ) << std::setw (2 ) << tm_struct.wDay ;
118
- oss << " ." << std::setfill (' 0' ) << std::setw (2 ) << tm_struct.wHour ;
119
- oss << std::setfill (' 0' ) << std::setw (2 ) << tm_struct.wMinute ;
120
- oss << std::setfill (' 0' ) << std::setw (2 ) << tm_struct.wSecond ;
121
- #else // UNIX, OSX
122
- oss << " ." << std::setfill (' 0' ) << std::setw (4 ) << tm_struct.tm_year + 1900 ;
123
- oss << std::setfill (' 0' ) << std::setw (2 ) << tm_struct.tm_mon + 1 ;
124
- oss << std::setfill (' 0' ) << std::setw (2 ) << tm_struct.tm_mday ;
125
- oss << " ." << std::setfill (' 0' ) << std::setw (2 ) << tm_struct.tm_hour ;
126
- oss << std::setfill (' 0' ) << std::setw (2 ) << tm_struct.tm_min ;
127
- oss << std::setfill (' 0' ) << std::setw (2 ) << tm_struct.tm_sec ;
128
- #endif
129
- oss << " ." << uv_os_getpid ();
130
- oss << " ." << std::setfill (' 0' ) << std::setw (3 ) << ++seq;
131
- oss << " .json" ;
112
+ filename = *DiagnosticFilename (env != nullptr ? env->thread_id () : 0 ,
113
+ " report" , " json" , seq++);
132
114
}
133
115
134
- filename = oss.str ();
135
116
// Open the report file stream for writing. Supports stdout/err,
136
117
// user-specified or (default) generated name
137
118
std::ofstream outfile;
0 commit comments