@@ -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)
@@ -273,7 +275,7 @@ static struct {
273275#if NODE_USE_V8_PLATFORM
274276 void Initialize (int thread_pool_size, uv_loop_t * loop) {
275277 if (trace_enabled) {
276- tracing_agent_.reset (new tracing::Agent ());
278+ tracing_agent_.reset (new tracing::Agent (trace_file_pattern ));
277279 platform_ = new NodePlatform (thread_pool_size, loop,
278280 tracing_agent_->GetTracingController ());
279281 V8::InitializePlatform (platform_);
@@ -3853,6 +3855,10 @@ static void PrintHelp() {
38533855 " --trace-events-enabled track trace events\n "
38543856 " --trace-event-categories comma separated list of trace event\n "
38553857 " 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 "
38563862 " --track-heap-objects track heap object allocations for heap "
38573863 " snapshots\n "
38583864 " --prof-process process v8 profiler output generated\n "
@@ -3979,6 +3985,7 @@ static void CheckIfAllowedInEnv(const char* exe, bool is_env,
39793985 " --force-async-hooks-checks" ,
39803986 " --trace-events-enabled" ,
39813987 " --trace-event-categories" ,
3988+ " --trace-event-file-pattern" ,
39823989 " --track-heap-objects" ,
39833990 " --zero-fill-buffers" ,
39843991 " --v8-pool-size" ,
@@ -4128,6 +4135,14 @@ static void ParseArgs(int* argc,
41284135 }
41294136 args_consumed += 1 ;
41304137 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;
41314146 } else if (strcmp (arg, " --track-heap-objects" ) == 0 ) {
41324147 track_heap_objects = true ;
41334148 } else if (strcmp (arg, " --throw-deprecation" ) == 0 ) {
0 commit comments