From f9df15e24eff474a7637d0567bce6743575460b0 Mon Sep 17 00:00:00 2001 From: Bart Polot Date: Thu, 13 Feb 2014 20:18:13 +0000 Subject: - extract peer information for filtering --- contrib/log.php | 62 ++++++++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 48 insertions(+), 14 deletions(-) diff --git a/contrib/log.php b/contrib/log.php index 6af3e57d4..9c7cf6d10 100644 --- a/contrib/log.php +++ b/contrib/log.php @@ -2,27 +2,35 @@ $path='log'; $lines = array(); +$peers = array(); $ajax = FALSE; function render_row ($d, $component, $pid, $level, $msg, $c) { global $ajax; + global $peers; if (!$ajax && $level == "DEBUG") return; - $date = $d ? $d->format('Y-m-d'). '
' . $d->format('H:i:s') : ""; - echo ""; - echo "$date"; - echo ''; + + list($comp,$peer) = explode (',', preg_replace ('/(.*)-(\d*)/', '\1,\2', $component)); + $peer = array_key_exists ($peer, $peers) ? $peers[$peer] : $peer; + $date = $d ? $d->format('Y-m-d'). $d->format('H:i:s') : ""; + echo ""; + echo "$date"; + echo ''; echo $d ? $d->format('u') : ""; - echo ''; - echo "$component$level$msg "; + echo ''; + echo "$comp$peer"; + echo "$level$msg "; if ($level != "DEBUG") { - echo ''; - echo ''; + echo '
'; + echo '
'; +// echo ''; } else - echo ''; + echo ''; + echo ''; } function render_rows () @@ -36,6 +44,7 @@ function render_rows () function process ($line, $c) { global $lines; + global $peers; $a = explode (' ', $line); if (count($a) < 6) return; @@ -43,6 +52,12 @@ function process ($line, $c) $component = $a[3]; $level = $a[4]; $msg = implode (' ', array_slice ($a, 5)); + + if (FALSE !== strpos($line, "STARTING SERVICE")) { + $id = preg_replace ("/.*\[(....)\].*\n/", '\1', $line); + $pid = preg_replace ("/.*[a-z-]*-([0-9]*).*\n/", '\1', $line); + $peers[$pid] = $id; + } $lines[] = array ($date, $component, 0, $level, $msg, $c); } @@ -68,10 +83,12 @@ $handle = @fopen($path, 'r'); if ($handle) { $c = 0; while (($line = fgets($handle)) !== false) { - if ((!$start || $c >= $start) && (!$stop || $c <= $stop)) { + if (!$start || $c >= $start) { process ($line, $c); } $c++; + if ($stop && $c > $stop) + break; } } else { echo "
Error opening file $path.
"; @@ -102,9 +119,10 @@ if ($start !== null || $stop !== null) { @@ -139,7 +167,12 @@ if ($start !== null || $stop !== null) { - + +
+ $id): ?> + + +
@@ -148,6 +181,7 @@ if ($start !== null || $stop !== null) { + -- cgit v1.2.3
Date Time uSec CompPeer Level Message