in reply to Tailing/Streaming a Log File into Any Web Browser from Daemon
well here's what i'm thinking to solve this.
when the initial page is loaded, create a file called log.old containing the current contents of the log file. Then have an ajax function run on a javascript refresh (every 5,10,30 seconds or whatever). If you anticipate a lot of date being transferred (2000+ chars or so) be sure to make the ajax function a post function, rather than get.
have this ajax function call a perl script that populates a new version of the log file, log.net. then run a 'diff log.old log.new' and store the result in a file/variable' then move log.new to log.old. doign this will help cut down on transferring the whole file every time. then just return the diff text from the ajax function
using the returned text, simply append it to either a div or a text area on that webpage using various DOM techniques
I'm fairly confident that this would work, it's just a matter of putting all the right pieces together. for all the ajax functions check out XMLHttpRequest
|
|---|