|
9 | 9 | StringPrototypeToLowerCase, |
10 | 10 | StringPrototypeToUpperCase, |
11 | 11 | } = primordials; |
12 | | -const wrapDebugLog = (set, logger) => { |
13 | | - const { hasInspector } = internalBinding('config'); |
14 | | - if (hasInspector) { |
15 | | - const { consoleCall } = internalBinding('inspector'); |
16 | | - const pid = process.pid; |
17 | | - return (...args) => { |
18 | | - const inspect = require('internal/util/inspector'); |
19 | | - return consoleCall((maybeFmt, ...args) => { |
20 | | - if (typeof maybeFmt === 'string') { |
21 | | - inspect.consoleFromVM.debug(`%s %i: ${maybeFmt}`, set, pid, ...args); |
22 | | - } else { |
23 | | - inspect.consoleFromVM.debug('%s %i:', set, pid, maybeFmt, ...args); |
24 | | - } |
25 | | - }, logger, ...args); |
26 | | - }; |
27 | | - } |
28 | | - return logger; |
29 | | -}; |
30 | | - |
31 | | -const { inspect, format, formatWithOptions } = require('internal/util/inspect'); |
32 | 12 |
|
33 | 13 | // `debugImpls` and `testEnabled` are deliberately not initialized so any call |
34 | 14 | // to `debuglog()` before `initializeDebugEnv()` is called will throw. |
@@ -69,12 +49,15 @@ function debuglogImpl(enabled, set) { |
69 | 49 | if (enabled) { |
70 | 50 | const pid = process.pid; |
71 | 51 | emitWarningIfNeeded(set); |
72 | | - debugImpls[set] = wrapDebugLog(set, function debug(...args) { |
73 | | - const colors = process.stderr.hasColors && process.stderr.hasColors(); |
74 | | - const msg = formatWithOptions({ colors }, ...args); |
75 | | - const coloredPID = inspect(pid, { colors }); |
76 | | - process.stderr.write(format('%s %s: %s\n', set, coloredPID, msg)); |
77 | | - }); |
| 52 | + debugImpls[set] = function debug(maybeFmt, ...args) { |
| 53 | + if (typeof maybeFmt === 'string') { |
| 54 | + // eslint-disable-next-line |
| 55 | + console.debug(`%s %i: ${maybeFmt}`, set, pid, ...args); |
| 56 | + } else { |
| 57 | + // eslint-disable-next-line |
| 58 | + console.debug('%s %i:', set, pid, maybeFmt, ...args); |
| 59 | + } |
| 60 | + }; |
78 | 61 | } else { |
79 | 62 | debugImpls[set] = noop; |
80 | 63 | } |
|
0 commit comments