diff --git a/lib/internal/bootstrap/node.js b/lib/internal/bootstrap/node.js index 33d79689d0993f..ca44196e88e8e3 100644 --- a/lib/internal/bootstrap/node.js +++ b/lib/internal/bootstrap/node.js @@ -18,7 +18,6 @@ /* global isMainThread */ const { - _setupTraceCategoryState, _setupNextTick, _setupPromises, _chdir, _cpuUsage, _hrtime, _hrtimeBigInt, @@ -384,7 +383,10 @@ function readAndExecuteStdin() { } function setupTraceCategoryState() { - const { traceCategoryState } = internalBinding('trace_events'); + const { + traceCategoryState, + setTraceCategoryStateUpdateHandler + } = internalBinding('trace_events'); const kCategoryAsyncHooks = 0; let traceEventsAsyncHook; @@ -406,7 +408,7 @@ function setupTraceCategoryState() { } toggleTraceCategoryState(); - _setupTraceCategoryState(toggleTraceCategoryState); + setTraceCategoryStateUpdateHandler(toggleTraceCategoryState); } function setupProcessObject() { diff --git a/src/bootstrapper.cc b/src/bootstrapper.cc index 0a1cfed2109e5c..de3eca8ba464a2 100644 --- a/src/bootstrapper.cc +++ b/src/bootstrapper.cc @@ -30,12 +30,6 @@ void RunMicrotasks(const FunctionCallbackInfo& args) { args.GetIsolate()->RunMicrotasks(); } -void SetupTraceCategoryState(const FunctionCallbackInfo& args) { - Environment* env = Environment::GetCurrent(args); - CHECK(args[0]->IsFunction()); - env->set_trace_category_state_function(args[0].As()); -} - void SetupNextTick(const FunctionCallbackInfo& args) { Environment* env = Environment::GetCurrent(args); Isolate* isolate = env->isolate(); @@ -136,7 +130,6 @@ void SetupPromises(const FunctionCallbackInfo& args) { // completes so that it can be gc'd as soon as possible. void SetupBootstrapObject(Environment* env, Local bootstrapper) { - BOOTSTRAP_METHOD(_setupTraceCategoryState, SetupTraceCategoryState); BOOTSTRAP_METHOD(_setupNextTick, SetupNextTick); BOOTSTRAP_METHOD(_setupPromises, SetupPromises); BOOTSTRAP_METHOD(_chdir, Chdir); diff --git a/src/node_trace_events.cc b/src/node_trace_events.cc index 1dfb1de2fcea1e..3c0f1cf68f1db8 100644 --- a/src/node_trace_events.cc +++ b/src/node_trace_events.cc @@ -11,6 +11,7 @@ namespace node { using v8::Array; using v8::Context; +using v8::Function; using v8::FunctionCallbackInfo; using v8::FunctionTemplate; using v8::Local; @@ -102,6 +103,13 @@ void GetEnabledCategories(const FunctionCallbackInfo& args) { } } +static void SetTraceCategoryStateUpdateHandler( + const FunctionCallbackInfo& args) { + Environment* env = Environment::GetCurrent(args); + CHECK(args[0]->IsFunction()); + env->set_trace_category_state_function(args[0].As()); +} + void NodeCategorySet::Initialize(Local target, Local unused, Local context, @@ -109,6 +117,9 @@ void NodeCategorySet::Initialize(Local target, Environment* env = Environment::GetCurrent(context); env->SetMethod(target, "getEnabledCategories", GetEnabledCategories); + env->SetMethod( + target, "setTraceCategoryStateUpdateHandler", + SetTraceCategoryStateUpdateHandler); Local category_set = env->NewFunctionTemplate(NodeCategorySet::New);