I'm trying to understand how to use Winston (NodeJS) by creating a logger with custom levels.
logger.js
var winston = require('winston');
var custom = {
levels: {
debug: 0,
log : 1,
info : 2,
ok : 3,
warn : 4,
cry : 5,
fail : 6
},
colors: {
debug: 'grey',
log : 'white',
info : 'cyan',
ok : 'green',
yay : 'blue',
warn : 'yellow',
cry : 'magenta',
fail : 'red'
}
};
var customLogger = new (winston.Logger)({
transports: [
new (winston.transports.Console)({ colorize:true, prettyPrint: true, level: 'fail', timestamp:false })
],
levels:custom.levels, colors:custom.colors
});
module.exports = customLogger;
//in includes.js
var logger = require('./lib/logger.js');
exports.logger = logger;
//in app.js
var logger = require('includes').logger
logger.cry("Wah Wah Wah");
But everytime I try to include my custom logger and use it I get:
RangeError: Maximum call stack size exceeded
What am I doing wrong here?