如何为winston.createLogger()提供不同的标签作为参数

时间:2019-03-19 03:42:33

标签: javascript node.js winston

var logger = winston.createLogger({
    format: combine(
        label({ label: 'abc' }),
        prettyPrint()
      ),
    transports: [ new winston.transports.Console() ]
  });

exports.logger = logger;

如果不是标签:“ abc”,我想传递“ pqr”,“ xyz”,怎么办?

1 个答案:

答案 0 :(得分:0)

您可以通过将动态值分配给如下所示的变量来实现:

    var dynamicValue = "abc"; // value can change
    var logger = winston.createLogger({
        format: combine(
            label({ label: dynamicValue }),
            prettyPrint()
          ),
        transports: [ new winston.transports.Console() ]
      });

    exports.logger = logger;