aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
Diffstat (limited to 'contrib')
-rw-r--r--contrib/log.php58
1 files changed, 43 insertions, 15 deletions
diff --git a/contrib/log.php b/contrib/log.php
index 2a4122105..4188800aa 100644
--- a/contrib/log.php
+++ b/contrib/log.php
@@ -3,6 +3,7 @@
3$path='log'; 3$path='log';
4$lines = array(); 4$lines = array();
5$peers = array(); 5$peers = array();
6$comps = array();
6$ajax = FALSE; 7$ajax = FALSE;
7$colors = array('#F00', '#F80', '#FF0', 8$colors = array('#F00', '#F80', '#FF0',
8 '#4F0', '#0A0', 9 '#4F0', '#0A0',
@@ -19,7 +20,7 @@ function render_row ($d, $component, $pid, $level, $msg, $c)
19 list($comp,$peer) = explode (',', preg_replace ('/(.*)-(\d*)/', '\1,\2', $component)); 20 list($comp,$peer) = explode (',', preg_replace ('/(.*)-(\d*)/', '\1,\2', $component));
20 $peer = array_key_exists ($peer, $peers) ? $peers[$peer] : $peer; 21 $peer = array_key_exists ($peer, $peers) ? $peers[$peer] : $peer;
21 $date = $d ? $d->format('Y-m-d'). $d->format('H:i:s') : ""; 22 $date = $d ? $d->format('Y-m-d'). $d->format('H:i:s') : "";
22 echo "<tr class=\"$level P-$peer\" id=\"$c\">"; 23 echo "<tr class=\"$level P-$peer C-$comp\" id=\"$c\">";
23 echo "<td class=\"date\"><small>$date</td>"; 24 echo "<td class=\"date\"><small>$date</td>";
24 echo '<td class="usec"><small>'; 25 echo '<td class="usec"><small>';
25 echo $d ? $d->format('u') : ""; 26 echo $d ? $d->format('u') : "";
@@ -30,7 +31,6 @@ function render_row ($d, $component, $pid, $level, $msg, $c)
30 { 31 {
31 echo '<td><div class="btn-group"><button class="btn btn-xs btn-default btn-showup"><span class="glyphicon glyphicon-chevron-up"></span></button>'; 32 echo '<td><div class="btn-group"><button class="btn btn-xs btn-default btn-showup"><span class="glyphicon glyphicon-chevron-up"></span></button>';
32 echo '<button class="btn btn-xs btn-default btn-showdown"><span class="glyphicon glyphicon-chevron-down"></span></button></div></td>'; 33 echo '<button class="btn btn-xs btn-default btn-showdown"><span class="glyphicon glyphicon-chevron-down"></span></button></div></td>';
33// echo '</td>';
34 } 34 }
35 else 35 else
36 echo '<td></td>'; 36 echo '<td></td>';
@@ -49,6 +49,7 @@ function process ($line, $c)
49{ 49{
50 global $lines; 50 global $lines;
51 global $peers; 51 global $peers;
52 global $comps;
52 $a = explode (' ', $line); 53 $a = explode (' ', $line);
53 if (count($a) < 6) 54 if (count($a) < 6)
54 return; 55 return;
@@ -64,6 +65,8 @@ function process ($line, $c)
64 } 65 }
65 66
66 $lines[] = array ($date, $component, 0, $level, $msg, $c); 67 $lines[] = array ($date, $component, 0, $level, $msg, $c);
68 $comp = preg_replace ('/(.*)-\d*/', '\1', $component);
69 $comps[$comp] = 1;
67} 70}
68 71
69if (array_key_exists ('a', $_GET)) { 72if (array_key_exists ('a', $_GET)) {
@@ -99,6 +102,7 @@ if ($handle) {
99} 102}
100 103
101$t1 = microtime(true); 104$t1 = microtime(true);
105/* Ajax request: don't render container HTML, just table rows. */
102if ($start !== null || $stop !== null) { 106if ($start !== null || $stop !== null) {
103 render_rows(); 107 render_rows();
104 die(); 108 die();
@@ -188,15 +192,22 @@ if ($start !== null || $stop !== null) {
188 <div class="btn-group"> 192 <div class="btn-group">
189 <button id="ERROR" class="btn btn-danger btn-showlevel"><span class="glyphicon glyphicon-fire"></span> Error</button> 193 <button id="ERROR" class="btn btn-danger btn-showlevel"><span class="glyphicon glyphicon-fire"></span> Error</button>
190 <button id="WARNING" class="btn btn-warning btn-showlevel"><span class="glyphicon glyphicon-exclamation-sign"></span> Warning</button> 194 <button id="WARNING" class="btn btn-warning btn-showlevel"><span class="glyphicon glyphicon-exclamation-sign"></span> Warning</button>
191 <button id="INFO" class="btn btn-info btn-showlevel active"><span class="glyphicon glyphicon glyphicon-info-sign"></span> Info</button> 195 <button id="INFO" class="btn btn-default btn-showlevel active"><span class="glyphicon glyphicon glyphicon-info-sign"></span> Info</button>
192 <button id="DEBUG" class="btn btn-default btn-showlevel"><span class="glyphicon glyphicon glyphicon-wrench"></span> Debug</button> 196 <button id="DEBUG" class="btn btn-primary btn-showlevel"><span class="glyphicon glyphicon glyphicon-wrench"></span> Debug</button>
193 </div> 197 </div>
194 <div class="btn-group"> 198 <div class="btn-group">
195 <?php foreach($peers as $pid=>$id): ?> 199 <?php foreach($peers as $pid=>$id): ?>
196 <button id="P-<?php echo $id ?>" class="btn btn-default btn-showpeer active"><?php echo $id ?></button> 200 <button id="P-<?php echo $id ?>" class="btn btn-default btn-element btn-showpeer active"><?php echo $id ?></button>
197 <?php endforeach ?> 201 <?php endforeach ?>
198 <button id="btn-showall" class="btn btn-default">All</button> 202 <button class="btn btn-default btn-showall">All</button>
199 <button id="btn-shownone" class="btn btn-default">None</button> 203 <button class="btn btn-default btn-shownone">None</button>
204 </div>
205 <div class="btn-group">
206 <?php foreach($comps as $c=>$one): ?>
207 <button id="C-<?php echo $c ?>" class="btn btn-default btn-element btn-showcomp active"><?php echo $c ?></button>
208 <?php endforeach ?>
209 <button class="btn btn-default btn-showall">All</button>
210 <button class="btn btn-default btn-shownone">None</button>
200 </div> 211 </div>
201</div> 212</div>
202<div id="msg" class="alert alert-success"></div> 213<div id="msg" class="alert alert-success"></div>
@@ -214,8 +225,10 @@ if ($start !== null || $stop !== null) {
214 </thead> 225 </thead>
215 <tbody> 226 <tbody>
216<?php render_rows(); ?> 227<?php render_rows(); ?>
217 </tbody> 228 </tbody>default
218</table> 229</table>
230<p>Processed in <?php echo $t1-$t0; ?> seconds.</p>
231<p>Rendered in <?php echo microtime(true)-$t1; ?> seconds.</p>
219 <!-- jQuery --> 232 <!-- jQuery -->
220 <script src="http://code.jquery.com/jquery-1.10.1.min.js"></script> 233 <script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
221 <!-- Latest compiled and minified Bootstrap JavaScript --> 234 <!-- Latest compiled and minified Bootstrap JavaScript -->
@@ -248,15 +261,14 @@ if ($start !== null || $stop !== null) {
248 } 261 }
249 } 262 }
250 263
251 function shownone() 264 function shownone(btn)
252 { 265 {
253 $(".btn-showpeer").removeClass("active"); 266 $(btn).parents(".btn-group").children(".btn-element.active").each(function(){$(this).click()});
254 $("tbody > tr").hide();
255 } 267 }
256 268
257 function showall() 269 function showall(btn)
258 { 270 {
259 $(".btn-showpeer:not(.active)").each(function(){showpeer(this.id)}); 271 $(btn).parents(".btn-group").children(".btn-element:not(.active)").each(function(){$(this).click()});
260 } 272 }
261 273
262 function showpeer (peer) 274 function showpeer (peer)
@@ -273,6 +285,21 @@ if ($start !== null || $stop !== null) {
273 $("."+peer).hide(); 285 $("."+peer).hide();
274 } 286 }
275 } 287 }
288
289 function showcomp (comp)
290 {
291 $("#"+comp).toggleClass("active");
292 if ($("#"+comp).hasClass("active")) {
293 for (var index = 0; index < types.length; ++index) {
294 var className = "." + types[index] + "." + comp;
295 $(className).show();
296 if ($("#"+types[index]).hasClass("active"))
297 return;
298 }
299 } else {
300 $("."+comp).hide();
301 }
302 }
276 303
277 function load_debug (btn, up) 304 function load_debug (btn, up)
278 { 305 {
@@ -337,8 +364,9 @@ if ($start !== null || $stop !== null) {
337 $(".btn-showdown").on ("click", function(){ load_debug(this, false) }); 364 $(".btn-showdown").on ("click", function(){ load_debug(this, false) });
338 $(".btn-showlevel").on ("click", function(){ showlevel(this.id) }); 365 $(".btn-showlevel").on ("click", function(){ showlevel(this.id) });
339 $(".btn-showpeer").on ("click", function(){ showpeer(this.id) }); 366 $(".btn-showpeer").on ("click", function(){ showpeer(this.id) });
340 $("#btn-showall").on ("click", function(){ showall() }); 367 $(".btn-showcomp").on ("click", function(){ showcomp(this.id) });
341 $("#btn-shownone").on ("click", function(){ shownone() }); 368 $(".btn-showall").on ("click", function(){ showall(this) });
369 $(".btn-shownone").on ("click", function(){ shownone(this) });
342 }); 370 });
343 </script> 371 </script>
344</body> 372</body>