Skip to content
Browse files

show last 5000 bytes with different colors for levels

  • Loading branch information...
1 parent 69e7696 commit 795fbd7bed552ca1706add51e9aabe12df7f29d0 @garrensmith garrensmith committed
Showing with 83 additions and 0 deletions.
  1. +1 −0 _attachments/index.html
  2. +32 −0 _attachments/script/futon.js
  3. +3 −0 _attachments/style/layout.css
  4. +47 −0 _attachments/templates/log.mustache
View
1 _attachments/index.html
@@ -40,6 +40,7 @@
<li><a href="#/_config">Configuration</a></li>
<li><a href="#/_replicate">Replicator</a></li>
<li><a href="#/_stats">Status</a></li>
+ <li><a href="#/_log">Log</a></li>
<li><a href="#/_tests">Test Suite</a></li>
</ul></li>
<li><span>Recent Databases</span>
View
32 _attachments/script/futon.js
@@ -763,6 +763,36 @@ app.showDatabase = function (context) {
.then(function () {init.call(this, context); moreRows(0,20);});
};
+app.showLog = function(context) {
+ this.title('Log');
+ $('span#topbar').html('<strong>Log</strong>');
+
+ var self = this;
+ var promise = $.get('/_log?bytes=5000');
+ promise.done(function (data) {
+ var logs = [];
+ var lines = data.split(/\n/);
+ $.each(lines, function (index, log) {
+ raw_items = log.split("]");
+ if (raw_items.length < 4) { return; }
+
+ // must be a better way of remove the "["
+ var log_row = {
+ date: raw_items[0].replace("["," "),
+ log_level: raw_items[1].replace("["," "),
+ pid: raw_items[2].replace("["," "),
+ args: raw_items[3].replace("["," "),
+ };
+
+ logs.push(log_row);
+ });
+
+ self.render('templates/log.mustache', {logs: logs})
+ .replace('#content');
+ });
+
+};
+
app.wildcard = function () {
var args = this.path.split('/');
args.splice(0,1);
@@ -833,6 +863,7 @@ var futonApp = $.sammy(function () {
this.get('#/_stats', app.showStats);
this.get('#/_tests', app.showTests);
this.get('#/_replicate', app.showReplicator);
+ this.get('#/_log', app.showLog);
this.get('#/:db/_views', app.showView); // TODO: see below...duplicate route?
this.get('#/:db/_design/:ddoc/_view/', app.showView);
@@ -850,5 +881,6 @@ var futonApp = $.sammy(function () {
// Document editor/viewer
this.get('#/:db/:docid', app.showDocument);
+
this.get(/\#\/(.*)/, app.wildcard);
});
View
3 _attachments/style/layout.css
@@ -141,6 +141,9 @@ table.listing thead th.desc span {
background-image: url(../image/order-desc.gif);
}
table.listing tbody tr th, table.listing tbody tr td { background: #feffea; }
+table.listing tbody tr th, table.listing tbody tr.error td { background: #DD7772; }
+table.listing tbody tr th, table.listing tbody tr.debug td { background: #60B1B8; }
+table.listing tbody tr th, table.listing tbody tr.info td { background: #feffea; }
table.listing tbody tr.odd th, table.listing tbody tr.odd td,
table.listing tbody.odd tr th, table.listing tbody.odd tr td {
background: #fff;
View
47 _attachments/templates/log.mustache
@@ -0,0 +1,47 @@
+<!--
+
+Licensed under the Apache License, Version 2.0 (the "License"); you may not use
+this file except in compliance with the License. You may obtain a copy of the
+License at
+
+http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software distributed
+under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR
+CONDITIONS OF ANY KIND, either express or implied. See the License for the
+specific language governing permissions and limitations under the License.
+
+-->
+<div id="log">
+ <table id="logs" class="listing" >
+ <caption>Logs</caption>
+ <thead>
+ <tr>
+ <th class="Date">Date</th>
+ <th class="Log Level">Log Value</th>
+ <th class="Pid">Pid</th>
+ <th class="Args">Url</th>
+ </tr>
+ </thead>
+
+ {{#logs}}
+ <tr class="{{log_level}}">
+ <td>
+ {{date}}
+ </td>
+ <td>
+ {{log_level}}
+ </td>
+ <td>
+ {{pid}}
+ </td>
+ <td>
+ {{args}}
+ </td>
+
+ </tr>
+ {{/logs}}
+ </table>
+</div>
+
+

0 comments on commit 795fbd7

Please sign in to comment.
Something went wrong with that request. Please try again.