var fs = require('fs'); var path = '/home/tknew/.forever/out-probe2.log'; var colors = [ '\x1B[34m', '\x1B[36m', '\x1B[32m', '\x1B[35m', '\x1B[31m', '\x1B[30m', '\x1B[90m', '\x1B[33m' ]; var gl_idx = 0; var db = []; function stream_log(title, path) { var currSize = fs.statSync(path).size; var odb = db[title] = {color : colors[gl_idx++]}; fs.watch(path, function(ev, filename) { if (ev == 'rename') return console.error('Renaming file ?'); fs.stat(path, function(err, stat) { var prevSize = stat.size; if (currSize > prevSize) return true; var rstream = fs.createReadStream(path, { encoding : 'utf8', start : currSize, end : prevSize }); rstream.on('data', function(data) { console.log(odb.color + '[%s]\x1B[39m %s', title, data.replace('\n', '')); }); currSize = stat.size; return true; }); return true; }); } stream_log('probe1', '/home/tknew/.forever/out-probe2.log'); stream_log('probe2', '/home/tknew/.forever/out-probe1.log');