在香草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"}