Only colorize output if logging to a tty (#11645)

This commit is contained in:
Andrew Berry authored and GitHub committed 2022-03-02 20:07:22 +01:00
1 parent 3535b2c6c2
commit 364a6dd2aa
1 file changed
+6 -1
+6 -1
View File
@@ -62,7 +62,12 @@ const transportsToUse: winston.transport[] = [
winston.format.printf(/* istanbul ignore next */(info) => {
const {timestamp, level, message} = info;
const l = winstonToZ2mLevel(level as WinstonLogLevel);
const prefix = colorizer.colorize(l, `Zigbee2MQTT:${levelWithCompensatedLength[l]}`);
const plainPrefix = `Zigbee2MQTT:${levelWithCompensatedLength[l]}`;
let prefix = plainPrefix;
if (process.stdout.isTTY) {
prefix = colorizer.colorize(l, plainPrefix);
}
return `${prefix} ${timestamp.split('.')[0]}: ${message}`;
}),
),