diff --git a/src/debug_utils-inl.h b/src/debug_utils-inl.h index 5593957c5b2c6b..ae2d2046486466 100644 --- a/src/debug_utils-inl.h +++ b/src/debug_utils-inl.h @@ -164,6 +164,20 @@ inline void FORCE_INLINE Debug(AsyncWrap* async_wrap, Debug(async_wrap, format.c_str(), std::forward(args)...); } +namespace per_process { + +template +inline void FORCE_INLINE Debug(DebugCategory cat, + const char* format, + Args&&... args) { + Debug(&enabled_debug_list, cat, format, std::forward(args)...); +} + +inline void FORCE_INLINE Debug(DebugCategory cat, const char* message) { + Debug(&enabled_debug_list, cat, message); +} + +} // namespace per_process } // namespace node #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS diff --git a/src/debug_utils.cc b/src/debug_utils.cc index 0f25a70e787bce..a601c5ecf40ea9 100644 --- a/src/debug_utils.cc +++ b/src/debug_utils.cc @@ -54,6 +54,9 @@ #endif // _WIN32 namespace node { +namespace per_process { +EnabledDebugList enabled_debug_list; +} void EnabledDebugList::Parse(Environment* env) { std::string cats; diff --git a/src/debug_utils.h b/src/debug_utils.h index 527e3549fa0e43..200f1cf07cd27b 100644 --- a/src/debug_utils.h +++ b/src/debug_utils.h @@ -161,6 +161,16 @@ class NativeSymbolDebuggingContext { void CheckedUvLoopClose(uv_loop_t* loop); void PrintLibuvHandleInformation(uv_loop_t* loop, FILE* stream); +namespace per_process { +extern EnabledDebugList enabled_debug_list; + +template +inline void FORCE_INLINE Debug(DebugCategory cat, + const char* format, + Args&&... args); + +inline void FORCE_INLINE Debug(DebugCategory cat, const char* message); +} // namespace per_process } // namespace node #endif // defined(NODE_WANT_INTERNALS) && NODE_WANT_INTERNALS diff --git a/src/node.cc b/src/node.cc index 23ac19479dddf4..fee485f86e17f1 100644 --- a/src/node.cc +++ b/src/node.cc @@ -862,6 +862,10 @@ void Init(int* argc, } InitializationResult InitializeOncePerProcess(int argc, char** argv) { + // Initialized the enabled list for Debug() calls with system + // environment variables. + per_process::enabled_debug_list.Parse(nullptr); + atexit(ResetStdio); PlatformInit();