Created
June 18, 2015 14:19
-
-
Save melihovv/e9b0af270d862b0ac9b6 to your computer and use it in GitHub Desktop.
Winston's wrapper for configurable logging.
This file contains 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'); | |
module.exports = function (module) { | |
return makeLogger(module.filename); | |
}; | |
function makeLogger(path) { | |
// File app.js -> log to console and file 'debug.log'. | |
if (path.match(/app.js$/)) { | |
var transports = [ | |
new winston.transports.Console({ | |
timestamp: true, | |
colorize: true, | |
level: 'info' | |
}), | |
new winston.transports.File({ | |
filename: 'debug.log', | |
level: 'debug' | |
}) | |
]; | |
return new winston.Logger({transports: transports}); | |
} else { | |
// Other files -> no logging. | |
return new winston.Logger({transports: []}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment