Skip to content

Commit

Permalink
adding log rotation to the logger
Browse files Browse the repository at this point in the history
  • Loading branch information
chelm committed Mar 18, 2015
1 parent 673acf7 commit 971f347
Showing 1 changed file with 13 additions and 2 deletions.
15 changes: 13 additions & 2 deletions lib/Logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,21 @@ function Logger( config ){

var transports;
if ( config.logfile ){

// we need a dir to do log rotation so we get the dir from the file
var logpath = config.logfile.split('/');
logpath.splice(-1,1);
logpath = logpath.join('/');

transports = [
// keep logging errors to the console (may not be needed)
//new (winston.transports.Console)({ level: 'error' }),
new (winston.transports.File)({ filename: config.logfile, level: 'debug' })
new (winston.transports.DailyRotateFile)({
filename: config.logfile,
dirname: logpath,
datePattern: '.yyyy-MM-dd',
colorize: true,
level: 'debug'
})
];
} else {
// no logfile defined, log to console only
Expand Down

0 comments on commit 971f347

Please sign in to comment.