Skip to content

Instantly share code, notes, and snippets.

@drzax
Created November 15, 2013 01:58
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save drzax/7477927 to your computer and use it in GitHub Desktop.
Save drzax/7477927 to your computer and use it in GitHub Desktop.
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