@@ -192,6 +192,8 @@ static node_module* modlist_linked;
192192static node_module* modlist_addon;
193193static bool trace_enabled = false ;
194194static std::string trace_enabled_categories; // NOLINT(runtime/string)
195+ static std::string trace_file_pattern = // NOLINT(runtime/string)
196+ " node_trace.${rotation}.log" ;
195197static bool abort_on_uncaught_exception = false ;
196198
197199// Bit flag used to track security reverts (see node_revert.h)
@@ -275,7 +277,7 @@ static struct {
275277#if NODE_USE_V8_PLATFORM
276278 void Initialize (int thread_pool_size) {
277279 if (trace_enabled) {
278- tracing_agent_.reset (new tracing::Agent ());
280+ tracing_agent_.reset (new tracing::Agent (trace_file_pattern ));
279281 platform_ = new NodePlatform (thread_pool_size,
280282 tracing_agent_->GetTracingController ());
281283 V8::InitializePlatform (platform_);
@@ -3422,6 +3424,10 @@ static void PrintHelp() {
34223424 " --trace-events-enabled track trace events\n "
34233425 " --trace-event-categories comma separated list of trace event\n "
34243426 " categories to record\n "
3427+ " --trace-event-file-pattern Template string specifying the\n "
3428+ " filepath for the trace-events data, it\n "
3429+ " supports ${rotation} and ${pid}\n "
3430+ " log-rotation id. %%2$u is the pid.\n "
34253431 " --track-heap-objects track heap object allocations for heap "
34263432 " snapshots\n "
34273433 " --prof-process process v8 profiler output generated\n "
@@ -3550,6 +3556,7 @@ static void CheckIfAllowedInEnv(const char* exe, bool is_env,
35503556 " --no-force-async-hooks-checks" ,
35513557 " --trace-events-enabled" ,
35523558 " --trace-event-categories" ,
3559+ " --trace-event-file-pattern" ,
35533560 " --track-heap-objects" ,
35543561 " --zero-fill-buffers" ,
35553562 " --v8-pool-size" ,
@@ -3701,6 +3708,14 @@ static void ParseArgs(int* argc,
37013708 }
37023709 args_consumed += 1 ;
37033710 trace_enabled_categories = categories;
3711+ } else if (strcmp (arg, " --trace-event-file-pattern" ) == 0 ) {
3712+ const char * file_pattern = argv[index + 1 ];
3713+ if (file_pattern == nullptr ) {
3714+ fprintf (stderr, " %s: %s requires an argument\n " , argv[0 ], arg);
3715+ exit (9 );
3716+ }
3717+ args_consumed += 1 ;
3718+ trace_file_pattern = file_pattern;
37043719 } else if (strcmp (arg, " --track-heap-objects" ) == 0 ) {
37053720 track_heap_objects = true ;
37063721 } else if (strcmp (arg, " --throw-deprecation" ) == 0 ) {
0 commit comments