Skip to content

Commit af442bd

Browse files
committed
fixup: simplify
1 parent 52d398c commit af442bd

File tree

1 file changed

+9
-26
lines changed

1 file changed

+9
-26
lines changed

lib/internal/util/debuglog.js

Lines changed: 9 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -9,26 +9,6 @@ const {
99
StringPrototypeToLowerCase,
1010
StringPrototypeToUpperCase,
1111
} = 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');
3212

3313
// `debugImpls` and `testEnabled` are deliberately not initialized so any call
3414
// to `debuglog()` before `initializeDebugEnv()` is called will throw.
@@ -69,12 +49,15 @@ function debuglogImpl(enabled, set) {
6949
if (enabled) {
7050
const pid = process.pid;
7151
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+
};
7861
} else {
7962
debugImpls[set] = noop;
8063
}

0 commit comments

Comments
 (0)