@@ -65,8 +65,7 @@ static void WriteNodeReport(Isolate* isolate,
65
65
const char * trigger,
66
66
const std::string& filename,
67
67
std::ostream& out,
68
- Local<String> stackstr,
69
- TIME_TYPE* tm_struct);
68
+ Local<String> stackstr);
70
69
static void PrintVersionInformation (JSONWriter* writer);
71
70
static void PrintJavaScriptStack (JSONWriter* writer,
72
71
Isolate* isolate,
@@ -79,7 +78,6 @@ static void PrintSystemInformation(JSONWriter* writer);
79
78
static void PrintLoadedLibraries (JSONWriter* writer);
80
79
static void PrintComponentVersions (JSONWriter* writer);
81
80
static void PrintRelease (JSONWriter* writer);
82
- static void LocalTime (TIME_TYPE* tm_struct);
83
81
84
82
// Global variables
85
83
static std::atomic_int seq = {0 }; // sequence number for report filenames
@@ -97,9 +95,6 @@ std::string TriggerNodeReport(Isolate* isolate,
97
95
std::shared_ptr<PerIsolateOptions> options;
98
96
if (env != nullptr ) options = env->isolate_data ()->options ();
99
97
100
- // Obtain the current time.
101
- TIME_TYPE tm_struct;
102
- LocalTime (&tm_struct);
103
98
// Determine the required report filename. In order of priority:
104
99
// 1) supplied on API 2) configured on startup 3) default generated
105
100
if (!name.empty ()) {
@@ -147,7 +142,7 @@ std::string TriggerNodeReport(Isolate* isolate,
147
142
}
148
143
149
144
WriteNodeReport (isolate, env, message, trigger, filename, *outstream,
150
- stackstr, &tm_struct );
145
+ stackstr);
151
146
152
147
// Do not close stdout/stderr, only close files we opened.
153
148
if (outfile.is_open ()) {
@@ -165,11 +160,7 @@ void GetNodeReport(Isolate* isolate,
165
160
const char * trigger,
166
161
Local<String> stackstr,
167
162
std::ostream& out) {
168
- // Obtain the current time and the pid (platform dependent)
169
- TIME_TYPE tm_struct;
170
- LocalTime (&tm_struct);
171
- WriteNodeReport (
172
- isolate, env, message, trigger, " " , out, stackstr, &tm_struct);
163
+ WriteNodeReport (isolate, env, message, trigger, " " , out, stackstr);
173
164
}
174
165
175
166
// Internal function to coordinate and write the various
@@ -180,8 +171,10 @@ static void WriteNodeReport(Isolate* isolate,
180
171
const char * trigger,
181
172
const std::string& filename,
182
173
std::ostream& out,
183
- Local<String> stackstr,
184
- TIME_TYPE* tm_struct) {
174
+ Local<String> stackstr) {
175
+ // Obtain the current time and the pid.
176
+ TIME_TYPE tm_struct;
177
+ DiagnosticFilename::LocalTime (&tm_struct);
185
178
uv_pid_t pid = uv_os_getpid ();
186
179
187
180
// Save formatting for output stream.
@@ -208,23 +201,23 @@ static void WriteNodeReport(Isolate* isolate,
208
201
snprintf (timebuf,
209
202
sizeof (timebuf),
210
203
" %4d-%02d-%02dT%02d:%02d:%02dZ" ,
211
- tm_struct-> wYear ,
212
- tm_struct-> wMonth ,
213
- tm_struct-> wDay ,
214
- tm_struct-> wHour ,
215
- tm_struct-> wMinute ,
216
- tm_struct-> wSecond );
204
+ tm_struct. wYear ,
205
+ tm_struct. wMonth ,
206
+ tm_struct. wDay ,
207
+ tm_struct. wHour ,
208
+ tm_struct. wMinute ,
209
+ tm_struct. wSecond );
217
210
writer.json_keyvalue (" dumpEventTime" , timebuf);
218
211
#else // UNIX, OSX
219
212
snprintf (timebuf,
220
213
sizeof (timebuf),
221
214
" %4d-%02d-%02dT%02d:%02d:%02dZ" ,
222
- tm_struct-> tm_year + 1900 ,
223
- tm_struct-> tm_mon + 1 ,
224
- tm_struct-> tm_mday ,
225
- tm_struct-> tm_hour ,
226
- tm_struct-> tm_min ,
227
- tm_struct-> tm_sec );
215
+ tm_struct. tm_year + 1900 ,
216
+ tm_struct. tm_mon + 1 ,
217
+ tm_struct. tm_mday ,
218
+ tm_struct. tm_hour ,
219
+ tm_struct. tm_min ,
220
+ tm_struct. tm_sec );
228
221
writer.json_keyvalue (" dumpEventTime" , timebuf);
229
222
struct timeval ts;
230
223
gettimeofday (&ts, nullptr );
@@ -619,14 +612,4 @@ static void PrintRelease(JSONWriter* writer) {
619
612
writer->json_objectend ();
620
613
}
621
614
622
- static void LocalTime (TIME_TYPE* tm_struct) {
623
- #ifdef _WIN32
624
- GetLocalTime (tm_struct);
625
- #else // UNIX, OSX
626
- struct timeval time_val;
627
- gettimeofday (&time_val, nullptr );
628
- localtime_r (&time_val.tv_sec , tm_struct);
629
- #endif
630
- }
631
-
632
615
} // namespace report
0 commit comments