Beefy Boxes and Bandwidth Generously Provided by pair Networks RobOMonk
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Tailing/Streaming a Log File into Any Web Browser from Daemon

by ickyb0d (Monk)
on Nov 17, 2005 at 10:52 UTC ( [id://509444]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


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

  • Comment on Re: Tailing/Streaming a Log File into Any Web Browser from Daemon

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://509444]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.