Skip to content

Instantly share code, notes, and snippets.

@beshur
Created March 18, 2016 14:24
Show Gist options
  • Save beshur/eec296ce78332db09657 to your computer and use it in GitHub Desktop.
Save beshur/eec296ce78332db09657 to your computer and use it in GitHub Desktop.
js Log wrapper and config for winston
/**
* Log wrapper and config
*
* @return module
*/
var winston = require('winston');
function getLogger(module) {
return new winston.Logger({
transports : [
new (winston.transports.Console)({
colorize: true,
level: 'debug'
}),
new (winston.transports.File)({
filename: 'app.log',
json: false,
maxsize: 15000000,
prettyPrint: true,
timestamp: function() {
var date = new Date();
date = date.toISOString();
return date;
},
formatter: function(data) {
return data.timestamp() + " [" + data.level + "] " + data.message + " " + JSON.stringify(data.meta);
}
})
]
});
}
module.exports = getLogger;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment