i was trying to get a Real tail -f type of viewer.
http://commavee.com/2007/04/13/ajax-logfile-tailer-viewer/ ( i got this to semi work But its not really buffering it) its rewriting the tail -20 every 2 seconds and not really Buffering it and making it scrollable (need to build something to eventually save the file as well but thats later) and if i try a tail -f the command will always execute and not stop
Do i need to consider some type of obflush *(i tried that with a ping tool i was working on and NO LUCK after days of research output_buffering=off was set in the php.ini)*
<?
// logtail.php
$cmd = "tail -20 /usr/local/bin/logs/outages.log";
exec("$cmd 2>&1", $output);
foreach($output as $outputline) {
echo ("$outputline\n");
}
?>
THIS IS LOGTAIL.JS
function getLog(timer) {
var url = "logtail.php";
request1.open("GET", url, true);
request1.onreadystatechange = updatePage;
request1.send(null);
startTail(timer);
}
function startTail(timer) {
if (timer == "stop") {
stopTail();
} else {
t= setTimeout("getLog()",1000);
}
}
function stopTail() {
clearTimeout(t);
var pause = "The log viewer has been paused. To begin viewing again, click the Start Viewer button.\r\n\r\n";
logDiv = document.getElementById("log");
var newNode=document.createTextNode(pause);
logDiv.replaceChild(newNode,logDiv.childNodes[0]);
}
function updatePage() {
if (request1.readyState == 4) {
if (request1.status == 200) {
var currentLogValue = request1.responseText.split("\n");
eval(currentLogValue);
logDiv = document.getElementById("log");
logDiv.scrollTop = logDiv.scrollHeight;
var logLine = ' ';
for (i=0; i < currentLogValue.length - 1; i++) {
logLine += currentLogValue[i] + "<br/>\n";
}
logDiv.innerHTML=logLine;
//} else
//alert("Error! Request status is " + request1.status);
}
}
}