Last active
August 29, 2015 14:05
-
-
Save ingshtrom/90f5ba133bed306a8255 to your computer and use it in GitHub Desktop.
The default logger config I use for my projects (minus loggly and logentries)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var winston = require('winston'), | |
config = require('./config'); | |
var consoleConfig, fileConfig; | |
// MODULE API | |
module.exports.logger = configure(); | |
// MODULE IMPLEMENTATIONS | |
function configure () { | |
// add our custom transports for all loggers | |
consoleConfig = { | |
level: config.consoleLogLevel, | |
colorize: true, | |
handleExceptions: false, | |
timestamp: true | |
}; | |
fileConfig = { | |
filename: config.defaultLogFile, | |
level: config.fileLogLevel, | |
maxsize: 102400, | |
handleExceptions: true, | |
timestamp: true | |
}; | |
winston.exitOnError = true; | |
return new (winston.Logger)({ | |
transports: [ | |
new (winston.transports.Console)(consoleConfig), | |
new (winston.transports.File)(fileConfig) | |
] | |
}); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment