aboutsummaryrefslogtreecommitdiff
path: root/contrib
diff options
context:
space:
mode:
Diffstat (limited to 'contrib')
-rw-r--r--contrib/log.php59
1 files changed, 49 insertions, 10 deletions
diff --git a/contrib/log.php b/contrib/log.php
index 09de9acf5..497e34f4b 100644
--- a/contrib/log.php
+++ b/contrib/log.php
@@ -31,14 +31,28 @@
31 .DEBUG { 31 .DEBUG {
32 background-color:#CCC; 32 background-color:#CCC;
33 } 33 }
34 .WARNING {
35 background-color:#EB9316;
36 }
37 .ERROR {
38 background-color:#D2322D;
39 }
34 40
35 </style> 41 </style>
36</head> 42</head>
37 43
38 44
39<body> 45<body>
40 46<div class="btn-toolbar" role="toolbar">
47 <div class="btn-group">
48 <button class="btn btn-danger btn-showerror"><span class="glyphicon glyphicon-fire"></span> Error</button>
49 <button class="btn btn-warning btn-showwarn"><span class="glyphicon glyphicon-exclamation-sign"></span> Warning</button>
50 <button class="btn btn-info btn-showinfo"><span class="glyphicon glyphicon glyphicon-info-sign"></span> Info</button>
51 <button class="btn btn-default btn-showdebug"><span class="glyphicon glyphicon glyphicon-wrench"></span> Debug</button>
52</div>
53</div>
41<table class="table"> 54<table class="table">
55 <thead>
42 <tr> 56 <tr>
43 <th>Date Time</th> 57 <th>Date Time</th>
44 <th>uSec</th> 58 <th>uSec</th>
@@ -47,36 +61,46 @@
47 <th>Message</th> 61 <th>Message</th>
48 <th></th> 62 <th></th>
49 </tr> 63 </tr>
64 </thead>
65 <tbody>
50<?php 66<?php
51 67
52$path='log'; 68$path='log';
53 69
54function render_row ($d, $component, $pid, $level, $msg) 70function render_row ($d, $component, $pid, $level, $msg)
55{ 71{
56 $date = $d->format('Y-m-d'). '<br />' . $d->format('H:i:s'); 72 $date = $d ? $d->format('Y-m-d'). '<br />' . $d->format('H:i:s') : "";
57 echo "<tr class=\"$level\">"; 73 echo "<tr class=\"$level\">";
58 echo "<td class=\"date\">$date</td>"; 74 echo "<td class=\"date\">$date</td>";
59 echo '<td class="usec">'; 75 echo '<td class="usec">';
60 echo $d->format('u'); 76 echo $d ? $d->format('u') : "";
61 echo '</td>'; 77 echo '</td>';
62 echo "<td class=\"comp\">$component</td><td class=\"level\">$level</td><td>$msg&nbsp;</td>"; 78 echo "<td class=\"comp\">$component</td><td class=\"level\">$level</td><td>$msg&nbsp;</td>";
63 echo '<td><button class="btn btn-xs btn-default btn-show"><span class="glyphicon glyphicon-plus"></span></button>'; 79 if ($level != "DEBUG")
64 echo '<button class="btn btn-xs btn-default btn-hide"><span class="glyphicon glyphicon-minus"></span></button></td></tr>'; 80 {
81 echo '<td><button class="btn btn-xs btn-default btn-show"><span class="glyphicon glyphicon-plus"></span></button>';
82 echo '<button class="btn btn-xs btn-default btn-hide"><span class="glyphicon glyphicon-minus"></span></button></td></tr>';
83 }
84 else
85 echo '<td></td></tr>';
65 $olddate = $date; 86 $olddate = $date;
66} 87}
67 88
68function process ($line) 89function process ($line)
69{ 90{
70 $a = explode (' ', $line); 91 $a = explode (' ', $line);
92 if (count($a) < 6)
93 return;
71 $date = DateTime::createFromFormat ("M d H:i:s-u", implode (' ', array_slice ($a, 0, 3))); 94 $date = DateTime::createFromFormat ("M d H:i:s-u", implode (' ', array_slice ($a, 0, 3)));
72 $component = $a[3]; 95 $component = $a[3];
73 $level = $a[4]; 96 $level = $a[4];
74 $msg = implode (' ', array_slice ($a, 5)); 97 $msg = implode (' ', array_slice ($a, 5));
75 98
76 render_row ($date, $component, 0, $level, $msg); 99 if ($level != "DEBUG")
100 render_row ($date, $component, 0, $level, $msg);
77} 101}
78 102
79 103$t0 = microtime(true);
80$handle = @fopen($path, 'r'); 104$handle = @fopen($path, 'r');
81if ($handle) { 105if ($handle) {
82 while (($line = fgets($handle)) !== false) { 106 while (($line = fgets($handle)) !== false) {
@@ -85,9 +109,11 @@ if ($handle) {
85} else { 109} else {
86 echo "<div class=\"alert alert-danger\">Error opening file $path.</div>"; 110 echo "<div class=\"alert alert-danger\">Error opening file $path.</div>";
87} 111}
112$t1 = microtime(true);
113// echo $t1-$t0;
88 114
89?> 115?>
90 116 </tbody>
91</table> 117</table>
92 <!-- jQuery --> 118 <!-- jQuery -->
93 <script src="http://code.jquery.com/jquery-1.10.1.min.js"></script> 119 <script src="http://code.jquery.com/jquery-1.10.1.min.js"></script>
@@ -96,24 +122,37 @@ if ($handle) {
96 122
97 <script> 123 <script>
98 124
125 var types = ["ERROR", "WARNING", "INFO", "DEBUG"];
126 function showt (level)
127 {
128 $("tr").hide();
129 for (var index = 0; index < types.length; ++index) {
130 $("."+types[index]).show();
131 if (types[index] == level)
132 return;
133 }
134 }
135
99 function show (btn) 136 function show (btn)
100 { 137 {
101 var tr = $(btn).parents("tr"); 138 var tr = $(btn).parents("tr");
102 tr.nextUntil("."+tr.attr("class")).show(); 139 tr.nextUntil("."+tr.attr("class")).show();
103 return;
104 } 140 }
105 141
106 function hide (btn) 142 function hide (btn)
107 { 143 {
108 var tr = $(btn).parents("tr"); 144 var tr = $(btn).parents("tr");
109 tr.nextUntil("."+tr.attr("class")).hide(); 145 tr.nextUntil("."+tr.attr("class")).hide();
110 return;
111 } 146 }
112 147
113 $(function() { 148 $(function() {
114 $(".DEBUG").hide(); 149 $(".DEBUG").hide();
115 $(".btn-show").on ("click", function(){ show(this) }); 150 $(".btn-show").on ("click", function(){ show(this) });
116 $(".btn-hide").on ("click", function(){ hide(this) }); 151 $(".btn-hide").on ("click", function(){ hide(this) });
152 $(".btn-showerror").on ("click", function(){ showt("ERROR") });
153 $(".btn-showwarn").on ("click", function(){ showt("WARNING") });
154 $(".btn-showinfo").on ("click", function(){ showt("INFO") });
155 $(".btn-showdebug").on ("click", function(){ showt("DEBUG") });
117 console.log( "ready!" ); 156 console.log( "ready!" );
118 }); 157 });
119 </script> 158 </script>