@@ -192,6 +192,8 @@ static node_module* modlist_linked;
192
192
static node_module* modlist_addon;
193
193
static bool trace_enabled = false ;
194
194
static std::string trace_enabled_categories; // NOLINT(runtime/string)
195
+ static std::string trace_file_pattern = // NOLINT(runtime/string)
196
+ " node_trace.${rotation}.log" ;
195
197
static bool abort_on_uncaught_exception = false ;
196
198
197
199
// Bit flag used to track security reverts (see node_revert.h)
@@ -273,7 +275,7 @@ static struct {
273
275
#if NODE_USE_V8_PLATFORM
274
276
void Initialize (int thread_pool_size, uv_loop_t * loop) {
275
277
if (trace_enabled) {
276
- tracing_agent_.reset (new tracing::Agent ());
278
+ tracing_agent_.reset (new tracing::Agent (trace_file_pattern ));
277
279
platform_ = new NodePlatform (thread_pool_size, loop,
278
280
tracing_agent_->GetTracingController ());
279
281
V8::InitializePlatform (platform_);
@@ -3853,6 +3855,10 @@ static void PrintHelp() {
3853
3855
" --trace-events-enabled track trace events\n "
3854
3856
" --trace-event-categories comma separated list of trace event\n "
3855
3857
" categories to record\n "
3858
+ " --trace-event-file-pattern Template string specifying the\n "
3859
+ " filepath for the trace-events data, it\n "
3860
+ " supports ${rotation} and ${pid}\n "
3861
+ " log-rotation id. %%2$u is the pid.\n "
3856
3862
" --track-heap-objects track heap object allocations for heap "
3857
3863
" snapshots\n "
3858
3864
" --prof-process process v8 profiler output generated\n "
@@ -3979,6 +3985,7 @@ static void CheckIfAllowedInEnv(const char* exe, bool is_env,
3979
3985
" --force-async-hooks-checks" ,
3980
3986
" --trace-events-enabled" ,
3981
3987
" --trace-event-categories" ,
3988
+ " --trace-event-file-pattern" ,
3982
3989
" --track-heap-objects" ,
3983
3990
" --zero-fill-buffers" ,
3984
3991
" --v8-pool-size" ,
@@ -4128,6 +4135,14 @@ static void ParseArgs(int* argc,
4128
4135
}
4129
4136
args_consumed += 1 ;
4130
4137
trace_enabled_categories = categories;
4138
+ } else if (strcmp (arg, " --trace-event-file-pattern" ) == 0 ) {
4139
+ const char * file_pattern = argv[index + 1 ];
4140
+ if (file_pattern == nullptr ) {
4141
+ fprintf (stderr, " %s: %s requires an argument\n " , argv[0 ], arg);
4142
+ exit (9 );
4143
+ }
4144
+ args_consumed += 1 ;
4145
+ trace_file_pattern = file_pattern;
4131
4146
} else if (strcmp (arg, " --track-heap-objects" ) == 0 ) {
4132
4147
track_heap_objects = true ;
4133
4148
} else if (strcmp (arg, " --throw-deprecation" ) == 0 ) {
0 commit comments