Skip to content

Instantly share code, notes, and snippets.

@drzax drzax/log.js

Created Nov 15, 2013
Embed
What would you like to do?
Re-emit a log file generated by Winston.
Tail = require('tail').Tail;
Winston = require('winston');
tail = new Tail('logs/default.log');
logger = new Winston.Logger();
logger.add(Winston.transports.Console, {colorize:true});
tail.on('line', function(data){
var json, date;
try {
json = JSON.parse(data);
data = json;
} catch (e) {
logger.error(data);
}
date = new Date(data.timestamp);
logger.log(data.level, date.toString() + ' ' + data.message);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.