Added log size setting when viewing syslog

This commit is contained in:
bergware
2022-05-29 17:00:09 +02:00
parent 303a2c1123
commit 2ffd132de0
2 changed files with 15 additions and 5 deletions

View File

@@ -32,7 +32,10 @@ if (file_exists($cfg)) {
}
$select = implode($select);
?>
<style>span.log{display:block}</style>
<style>
span.log{display:block}
input#max{border:none;width:60px;margin:0;padding:0}
</style>
<script>
var logfile = "<?=$log?>";
@@ -87,7 +90,7 @@ function showLog(log,init) {
$(this).removeClass().addClass(type+' label');
});
timers.syslog = setTimeout(function(){$('div.spinner.fixed').show('slow');},500);
$.post('/webGui/include/Syslog.php',{log:log},function(data){
$.post('/webGui/include/Syslog.php',{log:log,max:$('#max').val()||5000},function(data){
clearTimeout(timers.syslog);
$('pre.up').html(data);
<?if ($display['resize']):?>
@@ -98,9 +101,16 @@ function showLog(log,init) {
});
}
$(function() {
$('input#max').on('keydown',function(e) {
if (e.keyCode === 13) {
e.preventDefault();
e.stopImmediatePropagation();
showLog(logfile);
}
});
showLog(logfile,true);
});
$('.tabs').append("<span class='status'><?=$select?><span class='lite label'><label>_(Text)_<input type='checkbox' class='ctrl' onclick='highlight(!this.checked,\"N\")' checked></label></span><span class='error label'><label>_(Error)_<input type='checkbox' onclick='highlight(this.checked,\"E\")' checked></label></span><span class='warn label'><label>_(Warning)_<input type='checkbox' onclick='highlight(this.checked,\"W\")' checked></label></span><span class='system label'><label>_(System)_<input type='checkbox' onclick='highlight(this.checked,\"S\")' checked></label></span><span class='array label'><label>_(Array)_<input type='checkbox' onclick='highlight(this.checked,\"A\")' checked></label></span><span class='login label'><label>_(Login)_<input type='checkbox' onclick='highlight(this.checked,\"L\")' checked></label></span><span class='lite label'><input type='checkbox' class='ctrl' onclick='toggle(this.checked)' checked></span></span>");
$('.tabs').append("<span class='status'><span class='lite label'>_(Log size)_:&nbsp;&nbsp;<input type='number' id='max' value='' placeholder='5000'></span><?=$select?><span class='lite label'><label>_(Text)_<input type='checkbox' class='ctrl' onclick='highlight(!this.checked,\"N\")' checked></label></span><span class='error label'><label>_(Error)_<input type='checkbox' onclick='highlight(this.checked,\"E\")' checked></label></span><span class='warn label'><label>_(Warning)_<input type='checkbox' onclick='highlight(this.checked,\"W\")' checked></label></span><span class='system label'><label>_(System)_<input type='checkbox' onclick='highlight(this.checked,\"S\")' checked></label></span><span class='array label'><label>_(Array)_<input type='checkbox' onclick='highlight(this.checked,\"A\")' checked></label></span><span class='login label'><label>_(Login)_<input type='checkbox' onclick='highlight(this.checked,\"L\")' checked></label></span><span class='lite label'><input type='checkbox' class='ctrl' onclick='toggle(this.checked)' checked></span></span>");
</script>
<pre class='up'></pre>
<input type="button" id="download" value="_(Download)_" onclick="syslog(zipfile())"><input type="button" value="_(Refresh)_" onclick="showLog(logfile)"><input type="button" value="_(Done)_" onclick="done()">

View File

@@ -16,13 +16,13 @@ require_once "$docroot/webGui/include/ColorCoding.php";
array_multisort(array_map('filemtime',($logs = glob($_POST['log'].'*',GLOB_NOSORT))),SORT_ASC,$logs);
$sum = array_sum(array_map(function($log){return count(file($log));},$logs));
$max = 5000;
$max = $_POST['max'];
$row = 0;
foreach ($logs as $log) {
$fh = fopen($log,'r');
while (($line = fgets($fh)) !== false) {
if ($max < $sum - $row++) continue;
if ($max > 0 && $max < $sum - $row++) continue;
$span = '<span class="log text">';
foreach ($match as $type) foreach ($type['text'] as $text) if (preg_match("/$text/i",$line)) {
$span = '<span class="log '.$type['class'].'">';