summaryrefslogtreecommitdiff
path: root/lib/internal/util/debuglog.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/internal/util/debuglog.js')
-rw-r--r--lib/internal/util/debuglog.js8
1 files changed, 5 insertions, 3 deletions
diff --git a/lib/internal/util/debuglog.js b/lib/internal/util/debuglog.js
index 87af5de833..9834668307 100644
--- a/lib/internal/util/debuglog.js
+++ b/lib/internal/util/debuglog.js
@@ -1,6 +1,6 @@
'use strict';
-const { format } = require('internal/util/inspect');
+const { inspect, format, formatWithOptions } = require('internal/util/inspect');
// `debugs` is deliberately initialized to undefined so any call to
// debuglog() before initializeDebugEnv() is called will throw.
@@ -38,8 +38,10 @@ function debuglogImpl(set) {
const pid = process.pid;
emitWarningIfNeeded(set);
debugs[set] = function debug(...args) {
- const msg = format(...args);
- process.stderr.write(format('%s %d: %s\n', set, pid, msg));
+ 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));
};
} else {
debugs[set] = null;