Created
September 18, 2012 02:38
-
-
Save SimonGivre/3740951 to your computer and use it in GitHub Desktop.
JS tail server logs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var jq = document.createElement('script'); | |
jq.src = "http://code.jquery.com/jquery-latest.min.js"; | |
document.getElementsByTagName('head')[0].appendChild(jq); | |
function tail(){ | |
$.get(window.location.href+'?'+new Date().getTime(),function(data){ | |
var $newPre = $('<pre></pre>'); | |
var logArray = data.split('\n'); | |
var lineCount = logArray.length; | |
$newPre.append('Line count='+lineCount+'\n'); | |
var tail = ""; | |
var tailSize = 50; | |
for(var i=(lineCount-tailSize);i<lineCount;i++){ | |
tail = tail + (logArray[i]+'\n'); | |
} | |
$newPre.append(tail); | |
$('pre').remove(); | |
$('body').append($newPre); | |
}); | |
} | |
var id = setInterval(tail,1000); | |
console.log(id); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment