1

我面临与https://github.com/winstonjs/winston/issues/1416相同的logger.info('Hello there. How are you?');问题�[32minfo�[39m: �[32mHello there. How are you?�[39m

我不知道在哪里colorize可以删除它,这是我的代码:

  new winston.transports.File({
    format: winston.format.combine(
      winston.format.colorize({ // I added this but it's still not helping
        all: false,
        message: false,
        level: false,
      }),
      winston.format.label({ label: 'API' }),
      winston.format.timestamp(),
      winston.format.printf(({ level, message, label, timestamp }) => {
        return `${timestamp} [${label}] ${level}: ${message}`;
      }),
    ),
    filename: environment.logDirectory,
    level: 'http',
    maxsize: 1024 * 1024 * 10,
  }),

main.ts,我有

import { WINSTON_MODULE_NEST_PROVIDER } from 'nest-winston';
app.useLogger(app.get(WINSTON_MODULE_NEST_PROVIDER));

AppModule.ts中,我有以下内容:

import { WinstonModule } from 'nest-winston';
...
    WinstonModule.forRoot({
      transports,
    }),

我找不到任何使用的地方,colorize()我不知道如何禁用它。

我正在使用"nest-winston": "^1.4.0","winston": "^3.3.3",

4

1 回答 1

3

winston.format.uncolorize()方法添加到格式化选项以从您的 winston 输出中去除颜色编码

  format: winston.format.combine(
     winston.format.uncolorize()
     ...

干杯

于 2020-12-27T12:57:04.623 回答