Commit 399a4d86 authored by Franco Fichtner's avatar Franco Fichtner

logs: backport a display fix for empty logs

parent 754834e0
......@@ -346,7 +346,9 @@ function print_dump($logarr, $withorig)
foreach ($logarr as $logent) {
$logent = preg_split("/\s+/", $logent, 6);
echo "<tr valign=\"top\">\n";
if ($withorig) {
if ($logent[0] === 'File') {
echo "<td class=\"listlr\" colspan=\"2\">" . htmlspecialchars(join(' ', $logent)) . "</td>\n";
} elseif ($withorig) {
$entry_date_time = htmlspecialchars(join(" ", array_slice($logent, 0, 3)));
$entry_text = ($logent[3] == $config['system']['hostname']) ? "" : $logent[3] . " ";
$entry_text .= htmlspecialchars($logent[4] . " " . $logent[5]);
......@@ -379,12 +381,14 @@ function dump_clog($logfile, $tail, $withorig = true, $grepfor = '', $grepinvert
$logarr = array("File $logfile is a directory.");
} elseif (!file_exists($logfile)) {
$logarr = array("File $logfile doesn't exist.");
} elseif (filesize($logfile) == 0) {
$logarr = array("Log file started.");
} else {
exec("/usr/local/sbin/clog " . escapeshellarg($logfile) . "{$grepline}| grep -v \"CLOG\" | grep -v \"\033\" | /usr/bin/tail {$sor} -n " . escapeshellarg($tail), $logarr);
}
if (!count($logarr)) {
$logarr[] = sprintf(gettext('File %s yielded no results.'), $logfile);
}
print_dump($logarr, $withorig);
}
......@@ -405,15 +409,17 @@ function dump_log($logfile, $tail, $withorig = true, $grepfor = '', $grepinvert
}
if (is_dir($logfile)) {
$logarr = array("File $logfile is a directory.");
$logarr = array(sprintf(gettext('File %s is a directory.'), $logfile));
} elseif (!file_exists($logfile)) {
$logarr = array("File $logfile doesn't exist.");
} elseif (filesize($logfile) == 0) {
$logarr = array("Log file started.");
$logarr = array(sprintf(gettext('File %s doesn\'t exist.'), $logfile));
} else {
exec("cat " . escapeshellarg($logfile) . "{$grepline} | /usr/bin/tail {$sor} -n " . escapeshellarg($tail), $logarr);
}
if (!count($logarr)) {
$logarr[] = sprintf(gettext('File %s yielded no results.'), $logfile);
}
print_dump($logarr, $withorig);
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment