Tail Log Output with Node.js


/ Published in: JavaScript
Save to your folder(s)



Copy this code and paste it in your HTML
  1. // http://nodejs.org/api.html#_child_processes
  2. var sys = require('sys')
  3. var spawn = require('child_process').spawn;
  4. var filename = process.ARGV[2];
  5.  
  6. if (!filename)
  7. return sys.puts("Usage: node <server.js> <filename>");
  8.  
  9. var tail = spawn("tail", ["-f", filename]);
  10. sys.puts("start tailing");
  11.  
  12. tail.stdout.on("data", function (data) {
  13. sys.puts(data);
  14. });
  15.  
  16. // node tail.js development.log

URL: tail-log-output-with-node-js

Report this snippet


Comments

RSS Icon Subscribe to comments

You need to login to post a comment.