Merge pull request #5129 from node-red/fix-up-colors

Only apply colours for non-default log lines
pull/5121/head^2
Nick O'Leary 2025-05-02 09:28:13 +01:00 committed by GitHub
commit f8276ab61d
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 9 additions and 4 deletions

View File

@ -52,11 +52,11 @@ var levelColours = {
10: 'red',
20: 'red',
30: 'yellow',
40: 'white',
40: '',
50: 'cyan',
60: 'gray',
98: 'white',
99: 'white'
98: '',
99: ''
};
var logHandlers = [];
@ -99,7 +99,12 @@ const utilLog = function (msg, level) {
d.getMinutes().toString().padStart(2, '0'),
d.getSeconds().toString().padStart(2, '0')
].join(':');
console.log(chalk[levelColours[level] || 'white'](`${d.getDate()} ${months[d.getMonth()]} ${time} - ${msg}`))
const logLine = `${d.getDate()} ${months[d.getMonth()]} ${time} - ${msg}`
if (levelColours[level]) {
console.log(chalk[levelColours[level]](logLine))
} else {
console.log(logLine)
}
}
var consoleLogger = function(msg) {