Skip to content

Commit ec6cfd0

Browse files
committed
Strip ANSI code by default for plain text logger
1 parent dd9a6bd commit ec6cfd0

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/core/log.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ export interface LogMessageOptions {
3737
indent?: number;
3838
format?: (line: string) => string;
3939
colorize?: boolean;
40+
stripAnsiCode?: boolean;
4041
}
4142

4243
// deno-lint-ignore no-explicit-any
@@ -229,6 +230,7 @@ export class LogFileHandler extends FileHandler {
229230
...logRecord.args[0] as LogMessageOptions,
230231
bold: false,
231232
dim: false,
233+
stripAnsiCode: true,
232234
format: undefined,
233235
};
234236
let msg = applyMsgOptions(logRecord.msg, options);
@@ -417,7 +419,9 @@ function applyMsgOptions(msg: string, options: LogMessageOptions) {
417419
if (options.format) {
418420
msg = options.format(msg);
419421
}
420-
422+
if (options.stripAnsiCode) {
423+
msg = colors.stripAnsiCode(msg);
424+
}
421425
return msg;
422426
}
423427

0 commit comments

Comments
 (0)