记录多个参数不会在消息中显示全部

时间:2019-05-03 08:37:26

标签: winston

在香草JS中,通过以下代码,我得到“我喜欢苹果”

let fruit = 'apple'
console.log('i like', fruit)
i like apple

对于Winston,我只会得到第一个参数,即“我喜欢”

const logger = winston.createLogger({
  transports: [
    new winston.transports.Console(),
    new winston.transports.File({ filename: 'combined.log' })
  ]
});
logger.info('i like', fruit)
{"level":"info","message":"i like"}

字符串插值(https://github.com/winstonjs/winston#string-interpolation)是我唯一的方法

logger.info('i like %s', 'apple')
{"level":"info","message":"i like apple"}

0 个答案:

没有答案