Skip to content

Commit

Permalink
www: add $logsplit to log view templates
Browse files Browse the repository at this point in the history
  • Loading branch information
fichtner committed Aug 28, 2017
1 parent a91c23d commit 11f359c
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 6 deletions.
23 changes: 17 additions & 6 deletions src/www/diag_logs_common.inc
@@ -1,7 +1,7 @@
<?php

/*
Copyright (C) 2015-2016 Franco Fichtner <franco@opnsense.org>
Copyright (C) 2015-2017 Franco Fichtner <franco@opnsense.org>
Copyright (C) 2014 Deciso B.V.
Copyright (C) 2004 Scott Ullrich <sullrich@gmail.com>
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>
Expand Down Expand Up @@ -29,9 +29,13 @@
POSSIBILITY OF SUCH DAMAGE.
*/

if (!isset($logsplit)) {
$logsplit = 3;
}

function print_dump($logarr)
{
global $config;
global $config, $logsplit;

This comment has been minimized.

Copy link
@fabianfrz

fabianfrz Aug 28, 2017

Member

you may want to set a default value if it is not set.

This comment has been minimized.

Copy link
@fichtner

fichtner Aug 28, 2017

Author Member

See above, it's 3


if (!is_array($logarr)) {
echo "<tr>\n";
Expand All @@ -41,11 +45,18 @@ function print_dump($logarr)
}

foreach ($logarr as $logent) {
$logent = preg_split("/\s+/", $logent, 6);
$logent = preg_split('/\s+/', $logent);
if (count($logent) < $logsplit + 1) {
continue;
}
echo "<tr>\n";
$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]);
$entry_date_time = html_safe(join(' ', array_slice($logent, 0, $logsplit)));
$entry_text = '';
$hostname = $logent[$logsplit];
if ($hostname != $config['system']['hostname']) {
$entry_text = html_safe($hostname) . ' ';
}
$entry_text .= html_safe(join(' ', array_slice($logent, $logsplit + 1)));
echo "<td>{$entry_date_time}</td>\n";
echo "<td>{$entry_text}</td>\n";
echo "</tr>\n";
Expand Down
1 change: 1 addition & 0 deletions src/www/diag_logs_proxy.php
Expand Up @@ -7,6 +7,7 @@

$logfile = "/var/log/squid/{$type}.log";
$logclog = false;
$logsplit = 2;

$logpills = array();
$logpills[] = array(gettext('Cache'), true, '/diag_logs_proxy.php?type=cache');
Expand Down

0 comments on commit 11f359c

Please sign in to comment.