diff options
Diffstat (limited to 'contrib/log.php')
-rw-r--r-- | contrib/log.php | 62 |
1 files 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 @@ | |||
2 | 2 | ||
3 | $path='log'; | 3 | $path='log'; |
4 | $lines = array(); | 4 | $lines = array(); |
5 | $peers = array(); | ||
5 | $ajax = FALSE; | 6 | $ajax = FALSE; |
6 | 7 | ||
7 | function render_row ($d, $component, $pid, $level, $msg, $c) | 8 | function render_row ($d, $component, $pid, $level, $msg, $c) |
8 | { | 9 | { |
9 | global $ajax; | 10 | global $ajax; |
11 | global $peers; | ||
10 | if (!$ajax && $level == "DEBUG") | 12 | if (!$ajax && $level == "DEBUG") |
11 | return; | 13 | return; |
12 | $date = $d ? $d->format('Y-m-d'). '<br />' . $d->format('H:i:s') : ""; | 14 | |
13 | echo "<tr class=\"$level\" id=\"$c\">"; | 15 | list($comp,$peer) = explode (',', preg_replace ('/(.*)-(\d*)/', '\1,\2', $component)); |
14 | echo "<td class=\"date\"><small>$date</small></td>"; | 16 | $peer = array_key_exists ($peer, $peers) ? $peers[$peer] : $peer; |
15 | echo '<td class="usec">'; | 17 | $date = $d ? $d->format('Y-m-d'). $d->format('H:i:s') : ""; |
18 | echo "<tr class=\"$level $peer\" id=\"$c\">"; | ||
19 | echo "<td class=\"date\"><small>$date</td>"; | ||
20 | echo '<td class="usec"><small>'; | ||
16 | echo $d ? $d->format('u') : ""; | 21 | echo $d ? $d->format('u') : ""; |
17 | echo '</td>'; | 22 | echo '</small></td>'; |
18 | echo "<td class=\"comp\">$component</td><td class=\"level\">$level</td><td>$msg </td>"; | 23 | echo "<td class=\"comp\">$comp</td><td class=\"peer\">$peer</td>"; |
24 | echo "<td class=\"level\">$level</td><td>$msg </td>"; | ||
19 | if ($level != "DEBUG") | 25 | if ($level != "DEBUG") |
20 | { | 26 | { |
21 | echo '<td><button class="btn btn-xs btn-default btn-showup"><span class="glyphicon glyphicon-chevron-up"></span></button>'; | 27 | echo '<td><div class="btn-group"><button class="btn btn-xs btn-default btn-showup"><span class="glyphicon glyphicon-chevron-up"></span></button>'; |
22 | echo '<button class="btn btn-xs btn-default btn-showdown"><span class="glyphicon glyphicon-chevron-down"></span></button></td></tr>'; | 28 | echo '<button class="btn btn-xs btn-default btn-showdown"><span class="glyphicon glyphicon-chevron-down"></span></button></div></td>'; |
29 | // echo '</td>'; | ||
23 | } | 30 | } |
24 | else | 31 | else |
25 | echo '<td></td></tr>'; | 32 | echo '<td></td>'; |
33 | echo '</tr>'; | ||
26 | } | 34 | } |
27 | 35 | ||
28 | function render_rows () | 36 | function render_rows () |
@@ -36,6 +44,7 @@ function render_rows () | |||
36 | function process ($line, $c) | 44 | function process ($line, $c) |
37 | { | 45 | { |
38 | global $lines; | 46 | global $lines; |
47 | global $peers; | ||
39 | $a = explode (' ', $line); | 48 | $a = explode (' ', $line); |
40 | if (count($a) < 6) | 49 | if (count($a) < 6) |
41 | return; | 50 | return; |
@@ -43,6 +52,12 @@ function process ($line, $c) | |||
43 | $component = $a[3]; | 52 | $component = $a[3]; |
44 | $level = $a[4]; | 53 | $level = $a[4]; |
45 | $msg = implode (' ', array_slice ($a, 5)); | 54 | $msg = implode (' ', array_slice ($a, 5)); |
55 | |||
56 | if (FALSE !== strpos($line, "STARTING SERVICE")) { | ||
57 | $id = preg_replace ("/.*\[(....)\].*\n/", '\1', $line); | ||
58 | $pid = preg_replace ("/.*[a-z-]*-([0-9]*).*\n/", '\1', $line); | ||
59 | $peers[$pid] = $id; | ||
60 | } | ||
46 | 61 | ||
47 | $lines[] = array ($date, $component, 0, $level, $msg, $c); | 62 | $lines[] = array ($date, $component, 0, $level, $msg, $c); |
48 | } | 63 | } |
@@ -68,10 +83,12 @@ $handle = @fopen($path, 'r'); | |||
68 | if ($handle) { | 83 | if ($handle) { |
69 | $c = 0; | 84 | $c = 0; |
70 | while (($line = fgets($handle)) !== false) { | 85 | while (($line = fgets($handle)) !== false) { |
71 | if ((!$start || $c >= $start) && (!$stop || $c <= $stop)) { | 86 | if (!$start || $c >= $start) { |
72 | process ($line, $c); | 87 | process ($line, $c); |
73 | } | 88 | } |
74 | $c++; | 89 | $c++; |
90 | if ($stop && $c > $stop) | ||
91 | break; | ||
75 | } | 92 | } |
76 | } else { | 93 | } else { |
77 | echo "<div class=\"alert alert-danger\">Error opening file $path.</div>"; | 94 | echo "<div class=\"alert alert-danger\">Error opening file $path.</div>"; |
@@ -102,9 +119,10 @@ if ($start !== null || $stop !== null) { | |||
102 | <style> | 119 | <style> |
103 | body { | 120 | body { |
104 | font-family: arial,sans-serif; | 121 | font-family: arial,sans-serif; |
105 | color:#444; | 122 | /* color:#444; */ |
106 | } | 123 | } |
107 | table { | 124 | table { |
125 | margin-top: 40px; | ||
108 | font-size:12px; | 126 | font-size:12px; |
109 | border-collapse:collapse; | 127 | border-collapse:collapse; |
110 | } | 128 | } |
@@ -113,7 +131,11 @@ if ($start !== null || $stop !== null) { | |||
113 | position: fixed; | 131 | position: fixed; |
114 | width: 75%; | 132 | width: 75%; |
115 | left: 50%; | 133 | left: 50%; |
116 | margin: 0 0 0 -37.5%; | 134 | margin: 5% 0 0 -37.5%; |
135 | } | ||
136 | .btn-toolbar { | ||
137 | position: fixed; | ||
138 | top: 0px; | ||
117 | } | 139 | } |
118 | .level { | 140 | .level { |
119 | display: none; | 141 | display: none; |
@@ -127,7 +149,13 @@ if ($start !== null || $stop !== null) { | |||
127 | .ERROR { | 149 | .ERROR { |
128 | background-color:#D2322D; | 150 | background-color:#D2322D; |
129 | } | 151 | } |
130 | 152 | .btn-group { | |
153 | min-width: 48px; | ||
154 | } | ||
155 | table.table tbody tr td { | ||
156 | padding: 0px 0px 0px 4px; | ||
157 | margin-bottom: 0px; | ||
158 | } | ||
131 | </style> | 159 | </style> |
132 | </head> | 160 | </head> |
133 | 161 | ||
@@ -139,7 +167,12 @@ if ($start !== null || $stop !== null) { | |||
139 | <button class="btn btn-warning btn-showwarn"><span class="glyphicon glyphicon-exclamation-sign"></span> Warning</button> | 167 | <button class="btn btn-warning btn-showwarn"><span class="glyphicon glyphicon-exclamation-sign"></span> Warning</button> |
140 | <button class="btn btn-info btn-showinfo"><span class="glyphicon glyphicon glyphicon-info-sign"></span> Info</button> | 168 | <button class="btn btn-info btn-showinfo"><span class="glyphicon glyphicon glyphicon-info-sign"></span> Info</button> |
141 | <button class="btn btn-default btn-showdebug"><span class="glyphicon glyphicon glyphicon-wrench"></span> Debug</button> | 169 | <button class="btn btn-default btn-showdebug"><span class="glyphicon glyphicon glyphicon-wrench"></span> Debug</button> |
142 | </div> | 170 | </div> |
171 | <div class="btn-group"> | ||
172 | <?php foreach($peers as $pid=>$id): ?> | ||
173 | <button class="btn btn-default active"><?php echo $id ?></button> | ||
174 | <?php endforeach ?> | ||
175 | </div> | ||
143 | </div> | 176 | </div> |
144 | <div id="msg" class="alert alert-success"></div> | 177 | <div id="msg" class="alert alert-success"></div> |
145 | <table class="table"> | 178 | <table class="table"> |
@@ -148,6 +181,7 @@ if ($start !== null || $stop !== null) { | |||
148 | <th>Date Time</th> | 181 | <th>Date Time</th> |
149 | <th>uSec</th> | 182 | <th>uSec</th> |
150 | <th>Comp</th> | 183 | <th>Comp</th> |
184 | <th>Peer</th> | ||
151 | <th class="level">Level</th> | 185 | <th class="level">Level</th> |
152 | <th>Message</th> | 186 | <th>Message</th> |
153 | <th></th> | 187 | <th></th> |