【问题标题】:Winston Colorizer throwing errorWinston Colorizer 投掷错误
【发布时间】:2018-12-10 14:49:37
【问题描述】:

将温斯顿更新到 3.0.0 运行我的 nodejs 应用程序时出现此错误 出现以下错误

  TypeError: colors[Colorizer.allColors[lookup]] is not a function

【问题讨论】:

    标签: winston


    【解决方案1】:

    如果您要向 Winston 配置添加自定义颜色,则只能使用由 colors 包定义的颜色。 这就是我遇到的问题。

    【讨论】:

    • 我更改了 winston 配置并解决了我的错误“格式:winston.format.combine(winston.format.colorize({ all: true }), winston.format.simple())”
    【解决方案2】:

    如果您使用format.colorize,则必须注意始终指明日志级别。

    您可以将其指示为初始参数,在本例中为“错误”:

    logger.log('error', 'hello', { message: 'world' });
    

    你可以调用它的具体方法:

    logger.error('hello', { message: 'world' });
    

    如果您在任何时候省略级别,就会出现您遇到的问题;例如,如果你写这样的东西:

    logger.log('hello', { message: 'world' });
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-11-28
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2014-07-28
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多