Created
March 18, 2016 14:24
-
-
Save beshur/eec296ce78332db09657 to your computer and use it in GitHub Desktop.
js Log wrapper and config for winston
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
/** | |
* 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