Created
September 6, 2012 08:28
-
-
Save piscis/3653048 to your computer and use it in GitHub Desktop.
Formats a logfile with json objects seperated by linebreaks and prettyfies it
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
/** | |
* npm install carrier | |
* npm install parser | |
* tail -f /tmp/json.log | node logtest.js | |
* | |
* Logfile example: | |
* {"level":"info","message":"beep boop"} | |
* {"level":"error","message":"foo bar"} | |
*/ | |
var carrier = require('carrier'); | |
var parser = carrier.carry(process.stdin); | |
var util = require('util'); | |
var prettyjson = require('prettyjson'); | |
parser.on('line', function(line) { | |
var d = JSON.parse(line); | |
console.log(prettyjson.render(d)); | |
}); | |
process.stdin.resume(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment