我已阅读使用winston 包登录node.js 的文档。
我的问题:我是否需要将日志模块添加到需要的每个页面logging..
还是温斯顿以某种方式拦截console.log
and console.error
.
谢谢你的时间。
通常,您需要在使用它的模块中引入记录器。
不过,您可以按照以下建议@spmason https://github.com/spmason要点日志记录.js https://gist.github.com/spmason/1670196或者是什么@fega https://github.com/fega在他的建议中comment https://gist.github.com/spmason/1670196#gistcomment-2189760重新定义属性console
Object:
console.log = (...args) => logger.info.call(logger, ...args);
console.info = (...args) => logger.info.call(logger, ...args);
console.warn = (...args) => logger.warn.call(logger, ...args);
console.error = (...args) => logger.error.call(logger, ...args);
console.debug = (...args) => logger.debug.call(logger, ...args);
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)