Created
March 28, 2012 18:44
-
-
Save broncha/2229321 to your computer and use it in GitHub Desktop.
pseudo tail in nodejs
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
var fs = require('fs'); | |
var lastSize = 139658900; | |
var timer = setInterval(function(){ | |
fs.stat("E:/wamp/logs/access.log",function(err,stats){ | |
if(stats.size > lastSize){ | |
var buf = fs.createReadStream("E:/wamp/logs/access.log",{start:lastSize,end:stats.size}); | |
buf.setEncoding('utf8'); | |
buf.on('data',function(data){ | |
console.log(data); | |
}); | |
} | |
lastSize = stats.size; | |
}); | |
},5000); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment