GNUnet  0.10.x
Functions | Variables
log.php File Reference

Go to the source code of this file.

Functions

 render_row ($d, $component, $pid, $level, $msg, $c)
 
 render_rows ()
 
 process ($line, $c)
 

Variables

 $path ='log'
 
 $lines = array()
 
 $peers = array()
 
 $comps = array()
 
 $ajax = FALSE
 
 $colors
 
if(array_key_exists('a', $_GET)) else
 
 $t0 = microtime(true)
 
 $handle = @fopen($path, 'r')
 
 $t1 = microtime(true)
 
 $c = 0
 
 foreach ( $peers as $pid=> $id) echo "'$pid'
 

Function Documentation

◆ render_row()

render_row (   $d,
  $component,
  $pid,
  $level,
  $msg,
  $c 
)

Definition at line 13 of file log.php.

References $ajax, $peers, echo, and list.

Referenced by render_rows().

14 {
15  global $ajax;
16  global $peers;
17  if (!$ajax && $level == "DEBUG")
18  return;
19 
20  list($comp,$peer) = explode (',', preg_replace ('/(.*)-(\d*)/', '\1,\2', $component));
21  $peer = array_key_exists ($peer, $peers) ? $peers[$peer] : $peer;
22  $date = $d ? $d->format('Y-m-d'). $d->format('H:i:s') : "";
23  echo "<tr class=\"$level P-$peer C-$comp\" id=\"$c\">";
24  echo "<td class=\"date\"><small>$date</td>";
25  echo '<td class="usec"><small>';
26  echo $d ? $d->format('u') : "";
27  echo '</small></td>';
28  echo "<td class=\"comp\">$comp</td><td class=\"peer\">$peer</td>";
29  echo "<td class=\"level\">$level</td><td><pre>$msg</pre></td>";
30  if ($level != "DEBUG")
31  {
32  echo '<td><div class="btn-group"><button class="btn btn-xs btn-default btn-showup"><span class="glyphicon glyphicon-chevron-up"></span></button>';
33  echo '<button class="btn btn-xs btn-default btn-showdown"><span class="glyphicon glyphicon-chevron-down"></span></button></div></td>';
34  }
35  else
36  echo '<td></td>';
37  echo '</tr>';
38 }
static int echo
Request echo service.
Definition: gnunet-cadet.c:67
$ajax
Definition: log.php:7
$peers
Definition: log.php:5
static int list
Set if we should print a list of currently running services.
Definition: gnunet-arm.c:64
Here is the caller graph for this function:

◆ render_rows()

render_rows ( )

Definition at line 40 of file log.php.

References $lines, and render_row().

41 {
42  global $lines;
43  foreach ($lines as $line) {
44  render_row ($line[0], $line[1], $line[2], $line[3], $line[4], $line[5]);
45  }
46 }
$lines
Definition: log.php:4
render_row($d, $component, $pid, $level, $msg, $c)
Definition: log.php:13
Here is the call graph for this function:

◆ process()

process (   $line,
  $c 
)

Definition at line 48 of file log.php.

References $ajax, $c, $comps, $lines, and $peers.

49 {
50  global $lines;
51  global $peers;
52  global $comps;
53  $a = explode (' ', $line);
54  if (count($a) < 6)
55  return;
56  $date = DateTime::createFromFormat ("M d H:i:s-u", implode (' ', array_slice ($a, 0, 3)));
57  $component = $a[3];
58  $level = $a[4];
59  $msg = implode (' ', array_slice ($a, 5));
60 
61  if (FALSE !== strpos($line, "STARTING SERVICE")) {
62  $id = preg_replace ("/.*\[(....)\].*\n/", '\1', $line);
63  $pid = preg_replace ("/.*[a-z-]*-([0-9]*).*\n/", '\1', $line);
64  $peers[$pid] = $id;
65  }
66 
67  $lines[] = array ($date, $component, 0, $level, $msg, $c);
68  $comp = preg_replace ('/(.*)-\d*/', '\1', $component);
69  $comps[$comp] = 1;
70 }
71 
72 if (array_key_exists ('a', $_GET)) {
73  $start = (int)$_GET['a'];
74  $ajax= TRUE;
75 }
76 else
77 {
78  $start = null;
79 }
80 if (array_key_exists ('z', $_GET)) {
81  $stop = (int)$_GET['z'];
82  $ajax= TRUE;
83 }
84 else
85 {
86  $stop = null;
87 }
88 $t0 = microtime(true);
89 $handle = @fopen($path, 'r');
90 if ($handle) {
91  $c = 0;
92  while (($line = fgets($handle)) !== false) {
93  if (!$start || $c >= $start) {
94  process ($line, $c);
95  }
96  $c++;
97  if ($stop && $c > $stop)
98  break;
99  }
100 } else {
101  echo "<div class=\"alert alert-danger\">Error opening file $path.</div>";
102 }
103 
104 $t1 = microtime(true);
105 /* Ajax request: don't render container HTML, just table rows. */
106 if ($start !== null || $stop !== null) {
107  render_rows();
108  die();
109 }
110 // echo $t1-$t0;
111 ksort($peers);
112 ksort($comps);
113 ?>
114 <!DOCTYPE html>
115 <html lang="en">
116 <head>
117  <meta charset="utf-8">
118  <meta http-equiv="X-UA-Compatible" content="IE=edge">
119  <meta name="viewport" content="width=device-width, initial-scale=1">
120 
121  <title>GNUnet log view</title>
122 
123  <!-- Latest compiled and minified Bootstrap CSS -->
124  <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap.min.css">
125  <!-- Optional theme -->
126  <link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.1.0/css/bootstrap-theme.min.css">
127 
128  <style>
129  body {
130  font-family: arial,sans-serif;
131  }
132  table {
133  color:#000;
134  margin-top: 40px;
135  font-size:12px;
136  border-collapse:collapse;
137  }
138  pre {
139  padding: 0px;
140  margin: 0px;
141  border: 0px;
142  background-color: transparent;
143  }
144  .alert {
145  display: none;
146  position: fixed;
147  width: 75%;
148  left: 50%;
149  margin: 5% 0 0 -37.5%;
150  }
151  .btn-toolbar {
152  position: fixed;
153  top: 0px;
154  }
155  .btn-xs {
156  font-size: 9px;
157  padding: 0 5px;
158  }
159  .level {
160  display: none;
161  }
162  .DEBUG {
163  background-color:#CCC;
164  }
165  .WARNING {
166  background-color:#EB9316;
167  }
168  .ERROR {
169  background-color:#D2322D;
170  }
171  .btn-group {
172  min-width: 48px;
173  }
174  table.table tbody tr td,
175  table.table tbody th td {
176  padding: 0px 0px 0px 2px;
177  margin-bottom: 0px;
178  }
179 <?php
180  $c = 0;
181  foreach ($peers as $peer) {
182  echo "table.table tbody tr.P-$peer td.peer {\n";
183  echo ' background-color: ' . $colors[$c] . ";\n";
184  echo "}\n";
185  echo "#P-$peer { color: " . $colors[$c++] . "}\n";
186  } ?>
$c
Definition: log.php:180
process($line, $c)
Definition: log.php:48
static int echo
Request echo service.
Definition: gnunet-cadet.c:67
render_rows()
Definition: log.php:40
struct GNUNET_ATS_TEST_Topology * top
Definition: ats-testing.c:52
$lines
Definition: log.php:4
static struct PeerEntry ** table
Table with our interned peer IDs.
Definition: peer.c:54
$path
Definition: log.php:3
static unsigned int size
Size of the "table".
Definition: peer.c:66
const char * name
$handle
Definition: log.php:89
$colors
Definition: log.php:8
static struct PendingResolutions * head
Head of list of pending resolution requests.
Definition: gnunet-ats.c:228
$t0
Definition: log.php:88
$t1
Definition: log.php:104
static struct GNUNET_CONTAINER_MetaData * meta
Meta-data provided via command-line option.
$comps
Definition: log.php:6
$ajax
Definition: log.php:7
$peers
Definition: log.php:5

Variable Documentation

◆ $path

$path ='log'

Definition at line 3 of file log.php.

◆ $lines

$lines = array()

Definition at line 4 of file log.php.

Referenced by process(), and render_rows().

◆ $peers

$peers = array()

Definition at line 5 of file log.php.

Referenced by process(), and render_row().

◆ $comps

$comps = array()

Definition at line 6 of file log.php.

Referenced by process().

◆ $ajax

$ajax = FALSE

Definition at line 7 of file log.php.

Referenced by process(), and render_row().

◆ $colors

$colors
Initial value:
= array('#F00', '#F80', '#FF0',
'#4F0', '#0A0',
'#22F', '#ADF', '#0FF', '#F0F', '#508', '#FAA',
'#FFF', '#AAA', '#666', '#222')

Definition at line 8 of file log.php.

◆ else

if ( $handle) else
Initial value:
{
$start = null

Definition at line 77 of file log.php.

◆ $t0

$t0 = microtime(true)

Definition at line 88 of file log.php.

◆ $handle

$handle = @fopen($path, 'r')

Definition at line 89 of file log.php.

◆ $t1

$t1 = microtime(true)

Definition at line 104 of file log.php.

◆ $c

$c = 0

Definition at line 180 of file log.php.

Referenced by process().

◆ foreach

foreach($peers as $pid=> $id) echo "'$pid'

Definition at line 241 of file log.php.