I've set up Winston with transports to MySQL and console and put it in a module called logger
. Like so...
// modules/logger.js
/* require statements */
exports.logger = new (winston.Logger)({
transports: [
new winstonMysql(winstonMysqlConfig),
new (winston.transports.Console)
]
});
And then in /modules
// modules/index.js
/* grab other modules */
exports.logger = require('./logger.js');
When I do console.log(modules.logger)
, I get this
{ logger:
EventEmitter {
...
error: [Function],
warn: [Function],
info: [Function],
verbose: [Function],
debug: [Function],
silly: [Function],
...
}
}
But when I call modules.logger.info()
it throws modules.logger.info is not a function
error. What's wrong?
You aren't exporting the logger properly in modules.js
.
exports.logger = require('./logger.js').logger;