Skip to content

Commit

Permalink
Only detects ANSI color codes for data in string type
Browse files Browse the repository at this point in the history
Signed-off-by: Cocoa <0xbbc@0xbbc.com>
  • Loading branch information
BlueCocoa committed May 8, 2020
1 parent 40b5f09 commit 8cfe162
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/appenders/file.js
Expand Up @@ -56,7 +56,10 @@ function fileAppender(file, layout, logSize, numBackups, options, timezoneOffset
if (options.removeColor === true) {
// eslint-disable-next-line no-control-regex
const regex = /\x1b[[0-9;]*m/g;
loggingEvent.data = loggingEvent.data.map(d => d.replace(regex, ''))
loggingEvent.data = loggingEvent.data.map(d => {
if (typeof d === 'string') return d.replace(regex, '')
else return d
})
}
if (!writer.write(layout(loggingEvent, timezoneOffset) + eol, "utf8")) {
process.emit('log4js:pause', true);
Expand Down

0 comments on commit 8cfe162

Please sign in to comment.