From b05fd4baa87886674721101eaf38b75716037891 Mon Sep 17 00:00:00 2001 From: Joyee Cheung Date: Wed, 6 Mar 2019 12:54:12 +0100 Subject: lib: explicitly initialize debuglog during bootstrap This patch splits the implementation of util.debuglog into a separate file and explicitly initialize it during pre-execution since the initialization depends on environment variables. Also delays the call to `debuglog` in modules that are loaded during bootstrap to make sure we only access the environment variable during pre-execution. PR-URL: https://github.com/nodejs/node/pull/26468 Reviewed-By: Anna Henningsen Reviewed-By: Ruben Bridgewater --- lib/timers.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'lib/timers.js') diff --git a/lib/timers.js b/lib/timers.js index a7c795701e..d57b1ceb3e 100644 --- a/lib/timers.js +++ b/lib/timers.js @@ -42,7 +42,15 @@ const { const internalUtil = require('internal/util'); const util = require('util'); const { ERR_INVALID_CALLBACK } = require('internal/errors').codes; -const debug = util.debuglog('timer'); + +let debuglog; +function debug(...args) { + if (!debuglog) { + debuglog = require('internal/util/debuglog').debuglog('timer'); + } + debuglog(...args); +} + const { destroyHooksExist, // The needed emit*() functions. -- cgit v1.2.3