projects
/
oweals
/
gnunet.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
-indentation, doxygen, style
[oweals/gnunet.git]
/
contrib
/
log.php
diff --git
a/contrib/log.php
b/contrib/log.php
index 9a7f0a7764c5fd907d9d26ad069c36994ae8eb47..b2ca9ed6cde69f7cd88386b6851ba249532b7bf2 100644
(file)
--- a/
contrib/log.php
+++ b/
contrib/log.php
@@
-3,8
+3,12
@@
$path='log';
$lines = array();
$peers = array();
$path='log';
$lines = array();
$peers = array();
+$comps = array();
$ajax = FALSE;
$ajax = FALSE;
-$colors = array('#F00', '#0C0', '#44F', '#FF0', '#F0F', '#0FF');
+$colors = array('#F00', '#F80', '#FF0',
+ '#4F0', '#0A0',
+ '#22F', '#ADF', '#0FF', '#F0F', '#508', '#FAA',
+ '#FFF', '#AAA', '#666', '#222');
function render_row ($d, $component, $pid, $level, $msg, $c)
{
function render_row ($d, $component, $pid, $level, $msg, $c)
{
@@
-16,18
+20,17
@@
function render_row ($d, $component, $pid, $level, $msg, $c)
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') : "";
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 "<tr class=\"$level P-$peer\" id=\"$c\">";
+ echo "<tr class=\"$level P-$peer
C-$comp
\" id=\"$c\">";
echo "<td class=\"date\"><small>$date</td>";
echo '<td class="usec"><small>';
echo $d ? $d->format('u') : "";
echo '</small></td>';
echo "<td class=\"comp\">$comp</td><td class=\"peer\">$peer</td>";
echo "<td class=\"date\"><small>$date</td>";
echo '<td class="usec"><small>';
echo $d ? $d->format('u') : "";
echo '</small></td>';
echo "<td class=\"comp\">$comp</td><td class=\"peer\">$peer</td>";
- echo "<td class=\"level\">$level</td><td>
$msg
</td>";
+ echo "<td class=\"level\">$level</td><td>
<pre>$msg</pre>
</td>";
if ($level != "DEBUG")
{
echo '<td><div class="btn-group"><button class="btn btn-xs btn-default btn-showup"><span class="glyphicon glyphicon-chevron-up"></span></button>';
echo '<button class="btn btn-xs btn-default btn-showdown"><span class="glyphicon glyphicon-chevron-down"></span></button></div></td>';
if ($level != "DEBUG")
{
echo '<td><div class="btn-group"><button class="btn btn-xs btn-default btn-showup"><span class="glyphicon glyphicon-chevron-up"></span></button>';
echo '<button class="btn btn-xs btn-default btn-showdown"><span class="glyphicon glyphicon-chevron-down"></span></button></div></td>';
-// echo '</td>';
}
else
echo '<td></td>';
}
else
echo '<td></td>';
@@
-46,6
+49,7
@@
function process ($line, $c)
{
global $lines;
global $peers;
{
global $lines;
global $peers;
+ global $comps;
$a = explode (' ', $line);
if (count($a) < 6)
return;
$a = explode (' ', $line);
if (count($a) < 6)
return;
@@
-61,6
+65,8
@@
function process ($line, $c)
}
$lines[] = array ($date, $component, 0, $level, $msg, $c);
}
$lines[] = array ($date, $component, 0, $level, $msg, $c);
+ $comp = preg_replace ('/(.*)-\d*/', '\1', $component);
+ $comps[$comp] = 1;
}
if (array_key_exists ('a', $_GET)) {
}
if (array_key_exists ('a', $_GET)) {
@@
-96,12
+102,14
@@
if ($handle) {
}
$t1 = microtime(true);
}
$t1 = microtime(true);
+/* Ajax request: don't render container HTML, just table rows. */
if ($start !== null || $stop !== null) {
render_rows();
die();
}
// echo $t1-$t0;
if ($start !== null || $stop !== null) {
render_rows();
die();
}
// echo $t1-$t0;
-
+ksort($peers);
+ksort($comps);
?>
<!DOCTYPE html>
<html lang="en">
?>
<!DOCTYPE html>
<html lang="en">
@@
-122,12
+130,17
@@
if ($start !== null || $stop !== null) {
font-family: arial,sans-serif;
}
table {
font-family: arial,sans-serif;
}
table {
- font-family: courier,sans-serif;
color:#000;
margin-top: 40px;
font-size:12px;
border-collapse:collapse;
}
color:#000;
margin-top: 40px;
font-size:12px;
border-collapse:collapse;
}
+ pre {
+ padding: 0px;
+ margin: 0px;
+ border: 0px;
+ background-color: transparent;
+ }
.alert {
display: none;
position: fixed;
.alert {
display: none;
position: fixed;
@@
-139,6
+152,10
@@
if ($start !== null || $stop !== null) {
position: fixed;
top: 0px;
}
position: fixed;
top: 0px;
}
+ .btn-xs {
+ font-size: 9px;
+ padding: 0 5px;
+ }
.level {
display: none;
}
.level {
display: none;
}
@@
-176,15
+193,22
@@
if ($start !== null || $stop !== null) {
<div class="btn-group">
<button id="ERROR" class="btn btn-danger btn-showlevel"><span class="glyphicon glyphicon-fire"></span> Error</button>
<button id="WARNING" class="btn btn-warning btn-showlevel"><span class="glyphicon glyphicon-exclamation-sign"></span> Warning</button>
<div class="btn-group">
<button id="ERROR" class="btn btn-danger btn-showlevel"><span class="glyphicon glyphicon-fire"></span> Error</button>
<button id="WARNING" class="btn btn-warning btn-showlevel"><span class="glyphicon glyphicon-exclamation-sign"></span> Warning</button>
- <button id="INFO" class="btn btn-
info
btn-showlevel active"><span class="glyphicon glyphicon glyphicon-info-sign"></span> Info</button>
- <button id="DEBUG" class="btn btn-
default
btn-showlevel"><span class="glyphicon glyphicon glyphicon-wrench"></span> Debug</button>
+ <button id="INFO" class="btn btn-
default
btn-showlevel active"><span class="glyphicon glyphicon glyphicon-info-sign"></span> Info</button>
+ <button id="DEBUG" class="btn btn-
primary
btn-showlevel"><span class="glyphicon glyphicon glyphicon-wrench"></span> Debug</button>
</div>
</div>
- <div class="btn-group">
+ <div
id="btn-showpeer"
class="btn-group">
<?php foreach($peers as $pid=>$id): ?>
<?php foreach($peers as $pid=>$id): ?>
- <button id="P-<?php echo $id ?>" class="btn btn-default btn-showpeer active"><?php echo $id ?></button>
+ <button id="P-<?php echo $id ?>" class="btn btn-default btn-element active"><?php echo $id ?></button>
+ <?php endforeach ?>
+ <button class="btn btn-default btn-showall">All</button>
+ <button class="btn btn-default btn-shownone">None</button>
+ </div>
+ <div id="btn-showcomp" class="btn-group">
+ <?php foreach($comps as $c=>$one): ?>
+ <button id="C-<?php echo $c ?>" class="btn btn-default btn-element active"><?php echo $c ?></button>
<?php endforeach ?>
<?php endforeach ?>
- <button
id="btn-showall" class="btn btn-default
">All</button>
- <button
id="btn-shownone" class="btn btn-default
">None</button>
+ <button
class="btn btn-default btn-showall
">All</button>
+ <button
class="btn btn-default btn-shownone
">None</button>
</div>
</div>
<div id="msg" class="alert alert-success"></div>
</div>
</div>
<div id="msg" class="alert alert-success"></div>
@@
-202,8
+226,10
@@
if ($start !== null || $stop !== null) {
</thead>
<tbody>
<?php render_rows(); ?>
</thead>
<tbody>
<?php render_rows(); ?>
- </tbody>
+ </tbody>
default
</table>
</table>
+<p>Processed in <?php echo $t1-$t0; ?> seconds.</p>
+<p>Rendered in <?php echo microtime(true)-$t1; ?> seconds.</p>
<!-- jQuery -->
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<!-- Latest compiled and minified Bootstrap JavaScript -->
<!-- jQuery -->
<script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
<!-- Latest compiled and minified Bootstrap JavaScript -->
@@
-228,39
+254,60
@@
if ($start !== null || $stop !== null) {
$(".btn-showlevel").removeClass("active");
$("#"+level).addClass("active");
for (var index = 0; index < types.length; ++index) {
$(".btn-showlevel").removeClass("active");
$("#"+level).addClass("active");
for (var index = 0; index < types.length; ++index) {
- $(".btn-showpeer.active").each(function(){
- $("."+types[index]+"."+this.id).show();
+ $("#btn-showpeer > .btn-element.active").each(function(){
+ var peer = this.id;
+ $("#btn-showcomp > .btn-element.active").each(function(){
+ $("."+types[index]+"."+peer+"."+this.id).show();
+ });
});
if (types[index] == level)
return;
}
}
});
if (types[index] == level)
return;
}
}
- function shownone()
+ function shownone(
btn
)
{
{
- $(".btn-showpeer").removeClass("active");
- $("tbody > tr").hide();
+ $(btn).parents(".btn-group").children(".btn-element.active").each(function(){$(this).click()});
}
}
- function showall()
+ function showall(
btn
)
{
{
- $(
".btn-showpeer:not(.active)").each(function(){showpeer(this.id
)});
+ $(
btn).parents(".btn-group").children(".btn-element:not(.active)").each(function(){$(this).click(
)});
}
function showpeer (peer)
{
$("#"+peer).toggleClass("active");
if ($("#"+peer).hasClass("active")) {
}
function showpeer (peer)
{
$("#"+peer).toggleClass("active");
if ($("#"+peer).hasClass("active")) {
- for (var index = 0; index < types.length; ++index) {
- var className = "." + types[index] + "." + peer;
- $(className).show();
- if ($("#"+types[index]).hasClass("active"))
- return;
- }
+ $("#btn-showcomp > .btn-element.active").each(function(){
+ for (var index = 0; index < types.length; ++index) {
+ var className = "." + types[index] + "." + peer + "." + this.id;
+ $(className).show();
+ if ($("#"+types[index]).hasClass("active"))
+ return;
+ }
+ });
} else {
$("."+peer).hide();
}
}
} else {
$("."+peer).hide();
}
}
+
+ function showcomp (comp)
+ {
+ $("#"+comp).toggleClass("active");
+ if ($("#"+comp).hasClass("active")) {
+ $("#btn-showpeer > .btn-element.active").each(function(){
+ for (var index = 0; index < types.length; ++index) {
+ var className = "." + types[index] + "." + comp + "." + this.id;
+ $(className).show();
+ if ($("#"+types[index]).hasClass("active"))
+ return;
+ }
+ });
+ } else {
+ $("."+comp).hide();
+ }
+ }
function load_debug (btn, up)
{
function load_debug (btn, up)
{
@@
-299,10
+346,8
@@
if ($start !== null || $stop !== null) {
var loc = $("#"+(first-1));
var trs = $(resp);
for (var peer in peers) {
var loc = $("#"+(first-1));
var trs = $(resp);
for (var peer in peers) {
- console.log (peer + "=>" + peers[peer]);
trs.filter(".P-"+peer).removeClass('P-'+peer).addClass('P-'+peers[peer]).find("td.peer").html(peers[peer]);
}
trs.filter(".P-"+peer).removeClass('P-'+peer).addClass('P-'+peers[peer]).find("td.peer").html(peers[peer]);
}
- console.log (trs);
if (loc.length > 0)
loc.after(trs);
else {
if (loc.length > 0)
loc.after(trs);
else {
@@
-324,9
+369,10
@@
if ($start !== null || $stop !== null) {
$(".btn-showup").on ("click", function(){ load_debug(this, true) });
$(".btn-showdown").on ("click", function(){ load_debug(this, false) });
$(".btn-showlevel").on ("click", function(){ showlevel(this.id) });
$(".btn-showup").on ("click", function(){ load_debug(this, true) });
$(".btn-showdown").on ("click", function(){ load_debug(this, false) });
$(".btn-showlevel").on ("click", function(){ showlevel(this.id) });
- $(".btn-showpeer").on ("click", function(){ showpeer(this.id) });
- $("#btn-showall").on ("click", function(){ showall() });
- $("#btn-shownone").on ("click", function(){ shownone() });
+ $("#btn-showpeer > .btn-element").on ("click", function(){ showpeer(this.id) });
+ $("#btn-showcomp > .btn-element").on ("click", function(){ showcomp(this.id) });
+ $(".btn-showall").on ("click", function(){ showall(this) });
+ $(".btn-shownone").on ("click", function(){ shownone(this) });
});
</script>
</body>
});
</script>
</body>