@@ -197,6 +197,8 @@ static node_module* modlist_linked;
197
197
static node_module* modlist_addon;
198
198
static bool trace_enabled = false ;
199
199
static std::string trace_enabled_categories; // NOLINT(runtime/string)
200
+ static std::string trace_file_pattern = // NOLINT(runtime/string)
201
+ " node_trace.${rotation}.log" ;
200
202
static bool abort_on_uncaught_exception = false ;
201
203
202
204
// Bit flag used to track security reverts (see node_revert.h)
@@ -280,7 +282,7 @@ static struct {
280
282
#if NODE_USE_V8_PLATFORM
281
283
void Initialize (int thread_pool_size) {
282
284
if (trace_enabled) {
283
- tracing_agent_.reset (new tracing::Agent ());
285
+ tracing_agent_.reset (new tracing::Agent (trace_file_pattern ));
284
286
platform_ = new NodePlatform (thread_pool_size,
285
287
tracing_agent_->GetTracingController ());
286
288
V8::InitializePlatform (platform_);
@@ -3722,6 +3724,10 @@ static void PrintHelp() {
3722
3724
" --trace-events-enabled track trace events\n "
3723
3725
" --trace-event-categories comma separated list of trace event\n "
3724
3726
" categories to record\n "
3727
+ " --trace-event-file-pattern Template string specifying the\n "
3728
+ " filepath for the trace-events data, it\n "
3729
+ " supports ${rotation} and ${pid}\n "
3730
+ " log-rotation id. %%2$u is the pid.\n "
3725
3731
" --track-heap-objects track heap object allocations for heap "
3726
3732
" snapshots\n "
3727
3733
" --prof-process process v8 profiler output generated\n "
@@ -3850,6 +3856,7 @@ static void CheckIfAllowedInEnv(const char* exe, bool is_env,
3850
3856
" --no-force-async-hooks-checks" ,
3851
3857
" --trace-events-enabled" ,
3852
3858
" --trace-event-categories" ,
3859
+ " --trace-event-file-pattern" ,
3853
3860
" --track-heap-objects" ,
3854
3861
" --zero-fill-buffers" ,
3855
3862
" --v8-pool-size" ,
@@ -4001,6 +4008,14 @@ static void ParseArgs(int* argc,
4001
4008
}
4002
4009
args_consumed += 1 ;
4003
4010
trace_enabled_categories = categories;
4011
+ } else if (strcmp (arg, " --trace-event-file-pattern" ) == 0 ) {
4012
+ const char * file_pattern = argv[index + 1 ];
4013
+ if (file_pattern == nullptr ) {
4014
+ fprintf (stderr, " %s: %s requires an argument\n " , argv[0 ], arg);
4015
+ exit (9 );
4016
+ }
4017
+ args_consumed += 1 ;
4018
+ trace_file_pattern = file_pattern;
4004
4019
} else if (strcmp (arg, " --track-heap-objects" ) == 0 ) {
4005
4020
track_heap_objects = true ;
4006
4021
} else if (strcmp (arg, " --throw-deprecation" ) == 0 ) {
0 commit comments