我正在尝试测试一些Winston日志记录,并按此处发布的示例进行操作,但我无法运行此示例。
我已经将其复制/粘贴到我的js文件中,然后在vscode中按F5键来测试脚本。
什么都没有记录。
对于一个学习者来说,当像这样的例子无法正常工作时,如果您最终试图修复自己的环境,这将加倍困难。
有人可以告诉我这是否有效吗?
const { createLogger, format, transports } = require('winston');
const { combine, timestamp, label, prettyPrint } = format;
const logger = createLogger({
format: combine(
label({ label: 'right meow!' }),
timestamp(),
prettyPrint()
),
transports: [new transports.Console()]
})
logger.log({
level: 'info',
message: 'What time is the testing at?'
});
// Outputs:
// { level: 'info',
// message: 'What time is the testing at?',
// label: 'right meow!',
// timestamp: '2017-09-30T03:57:26.875Z' }
Run Code Online (Sandbox Code Playgroud)
我的nodeJS调试控制台只是退出并显示附加的调试器。等待调试器断开连接...