Skip to content

Instantly share code, notes, and snippets.

@broncha
Created March 28, 2012 18:44
Show Gist options
  • Save broncha/2229321 to your computer and use it in GitHub Desktop.
Save broncha/2229321 to your computer and use it in GitHub Desktop.
pseudo tail in nodejs
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