I have read the docs for logging in node.js using the winston package.
My question: Do I need to add my logging module to every single page that requires logging..
or does winston somehow intercept console.log
and console.error
.
thanks for your time.
Normally, you'd need to require your logger in the modules that use it.
However, you can follow the suggestion made by @spmason in the gist logging.js or what @fega suggests in his comment to redefine the properties of the 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);