diff --git a/lib/internal/util/debuglog.js b/lib/internal/util/debuglog.js index 68dd9976ac3e21..edf411d11684d6 100644 --- a/lib/internal/util/debuglog.js +++ b/lib/internal/util/debuglog.js @@ -9,26 +9,6 @@ const { StringPrototypeToLowerCase, StringPrototypeToUpperCase, } = primordials; -const wrapDebugLog = (set, logger) => { - const { hasInspector } = internalBinding('config'); - if (hasInspector) { - const { consoleCall } = internalBinding('inspector'); - const pid = process.pid; - return (...args) => { - const inspect = require('internal/util/inspector'); - return consoleCall((maybeFmt, ...args) => { - if (typeof maybeFmt === 'string') { - inspect.consoleFromVM.debug(`%s %i: ${maybeFmt}`, set, pid, ...args); - } else { - inspect.consoleFromVM.debug('%s %i:', set, pid, maybeFmt, ...args); - } - }, logger, ...args); - }; - } - return logger; -}; - -const { inspect, format, formatWithOptions } = require('internal/util/inspect'); // `debugImpls` and `testEnabled` are deliberately not initialized so any call // to `debuglog()` before `initializeDebugEnv()` is called will throw. @@ -69,12 +49,15 @@ function debuglogImpl(enabled, set) { if (enabled) { const pid = process.pid; emitWarningIfNeeded(set); - debugImpls[set] = wrapDebugLog(set, function debug(...args) { - const colors = process.stderr.hasColors && process.stderr.hasColors(); - const msg = formatWithOptions({ colors }, ...args); - const coloredPID = inspect(pid, { colors }); - process.stderr.write(format('%s %s: %s\n', set, coloredPID, msg)); - }); + debugImpls[set] = function debug(maybeFmt, ...args) { + if (typeof maybeFmt === 'string') { + // eslint-disable-next-line + console.debug(`%s %i: ${maybeFmt}`, set, pid, ...args); + } else { + // eslint-disable-next-line + console.debug('%s %i:', set, pid, maybeFmt, ...args); + } + }; } else { debugImpls[set] = noop; }