summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Kowalski <rok@kowalski.gd>2014-05-28 20:34:02 +0200
committerRobert Kowalski <rok@kowalski.gd>2014-05-29 12:07:25 +0200
commit17031e89f3d35286f0a04993a4dbcd710b484ea8 (patch)
tree2f52892723cb27dad242c54dc414c354fa31992f
parent11f726ec9e690abb5d40cdc77ee3860cbba4ff20 (diff)
downloadcouchdb-17031e89f3d35286f0a04993a4dbcd710b484ea8.tar.gz
Fauxton: remove the Log Component
As prepration for the BigCouch merge and a LTS Couch 1.x with Fauxton. After the merge the _logs resource will not be available and logging happens with Lager. See http://www.mail-archive.com/dev@couchdb.apache.org/msg32934.html for more details.
-rw-r--r--src/Makefile.am8
-rw-r--r--src/fauxton/TODO.md2
-rw-r--r--src/fauxton/app/addons/logs/assets/less/logs.less24
-rw-r--r--src/fauxton/app/addons/logs/base.js28
-rw-r--r--src/fauxton/app/addons/logs/resources.js212
-rw-r--r--src/fauxton/app/addons/logs/routes.js58
-rw-r--r--src/fauxton/app/addons/logs/templates/dashboard.html50
-rw-r--r--src/fauxton/app/addons/logs/templates/sidebar.html18
-rw-r--r--src/fauxton/app/addons/logs/tests/baseSpec.js38
-rw-r--r--src/fauxton/app/addons/logs/tests/resourcesSpec.js117
-rw-r--r--src/fauxton/assets/less/fauxton.less6
-rw-r--r--src/fauxton/settings.json.default1
-rw-r--r--src/fauxton/settings.json.dev1
13 files changed, 0 insertions, 563 deletions
diff --git a/src/Makefile.am b/src/Makefile.am
index dde0810c0..92ec8f1f9 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -77,13 +77,6 @@ FAUXTON_FILES = \
fauxton/app/addons/contribute/base.js \
fauxton/app/addons/exampleAuth/base.js \
fauxton/app/addons/exampleAuth/templates/noAccess.html \
- fauxton/app/addons/logs/base.js \
- fauxton/app/addons/logs/resources.js \
- fauxton/app/addons/logs/routes.js \
- fauxton/app/addons/logs/templates/dashboard.html \
- fauxton/app/addons/logs/templates/sidebar.html \
- fauxton/app/addons/logs/tests/baseSpec.js \
- fauxton/app/addons/logs/tests/resourcesSpec.js \
fauxton/app/addons/permissions/assets/less/permissions.less \
fauxton/app/addons/permissions/base.js \
fauxton/app/addons/permissions/resources.js \
@@ -321,7 +314,6 @@ FAUXTON_FILES = \
fauxton/app/addons/databases/assets/less/databases.less \
fauxton/assets/less/fauxton.less \
fauxton/assets/less/icons.less \
- fauxton/app/addons/logs/assets/less/logs.less \
fauxton/assets/less/prettyprint.less \
fauxton/assets/less/variables.less \
fauxton/bin/grunt \
diff --git a/src/fauxton/TODO.md b/src/fauxton/TODO.md
index b929e0546..a4b2a8e1a 100644
--- a/src/fauxton/TODO.md
+++ b/src/fauxton/TODO.md
@@ -21,6 +21,4 @@ In no particular order
- [ ] replicate UI
- [x] delete database
- [x] format dates better (e.g. in logs plugin)
-- [ ] format log entry better
-- [ ] filter logs by method
- [ ] restore unfiltered data in logs UI
diff --git a/src/fauxton/app/addons/logs/assets/less/logs.less b/src/fauxton/app/addons/logs/assets/less/logs.less
deleted file mode 100644
index 17a418254..000000000
--- a/src/fauxton/app/addons/logs/assets/less/logs.less
+++ /dev/null
@@ -1,24 +0,0 @@
-/* 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.
- */
-
-.logs {
- padding: 0 15px;
- .log-table {
- width: auto;
- white-space: nowrap;
- .args {
- width: 100%;
- white-space: normal;
- }
- }
-}
diff --git a/src/fauxton/app/addons/logs/base.js b/src/fauxton/app/addons/logs/base.js
deleted file mode 100644
index 1aecbdf6a..000000000
--- a/src/fauxton/app/addons/logs/base.js
+++ /dev/null
@@ -1,28 +0,0 @@
-// 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.
-
-define([
- "app",
-
- "api",
-
- // Modules
- "addons/logs/routes"
-],
-
-function(app, FauxtonAPI, Log) {
- Log.initialize = function() {
- FauxtonAPI.addHeaderLink({title: "Log", href: "#_log", icon: "fonticon-log", className: 'logs'});
- };
-
- return Log;
-});
diff --git a/src/fauxton/app/addons/logs/resources.js b/src/fauxton/app/addons/logs/resources.js
deleted file mode 100644
index cd0f54ae1..000000000
--- a/src/fauxton/app/addons/logs/resources.js
+++ /dev/null
@@ -1,212 +0,0 @@
-// 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.
-
-define([
- "app",
- "api",
- "backbone",
- "d3",
- "addons/fauxton/components"
-],
-
-function (app, FauxtonAPI, Backbone, d3, Components) {
-
- var Log = FauxtonAPI.addon();
-
- Log.Model = Backbone.Model.extend({
-
- initialize: function () {
- this.dateObject = new Date(this.get('date'));
- },
-
- date: function () {
- var formatter = d3.time.format("%b %e");
-
- return formatter(this.dateObject);
- },
-
- time: function () {
- var formatter = d3.time.format("%H:%M:%S");
-
- return formatter(this.dateObject);
- },
-
- logLevel: function () {
- return this.get('log_level').replace(/ /g,'');
- },
-
- pid: function () {
- return _.escape(this.get('pid'));
- },
-
- args: function () {
- return _.escape(this.get('args'));
- }
-
- });
-
- Log.Collection = Backbone.Collection.extend({
- model: Log.Model,
-
- initialize: function (options) {
- this.params = {bytes: 5000};
- },
-
- documentation: "log",
-
- url: function () {
- var query = "?" + $.param(this.params);
- return app.host + '/_log' + query;
- },
-
- // override fetch because backbone expects json and couchdb sends text/html for logs,
- // I think its more elegant to set the dataType here than where ever fetch is called
- fetch: function (options) {
- options = options ? options : {};
-
- return Backbone.Collection.prototype.fetch.call(this, _.extend(options, {dataType: "html"}));
- },
-
- sortLogsIntoDays: function () {
- return _.reduce(this.toArray(), function (sortedCollection, log, key) {
- var date = log.date();
-
- if (!sortedCollection[date]) {
- sortedCollection[date] = [];
- }
-
- sortedCollection[date].push(log);
- return sortedCollection;
- }, {});
- },
-
- parse: function (resp) {
- resp = resp.replace(/\n\s/g, '');
- var lines = resp.split(/\n/);
- return _.foldr(lines, function (acc, logLine) {
- var match = logLine.match(/^\[(.*?)\]\s\[(.*?)\]\s\[(.*?)\]\s(.*)/);
-
- if (!match) { return acc;}
-
- acc.push({
- date: match[1],
- log_level: match[2],
- pid: match[3],
- args: match[4].replace(/\s\s+/g, '')
- });
-
- return acc;
- }, []);
- }
- });
-
- Log.events = {};
- _.extend(Log.events, Backbone.Events);
-
- Log.Views.View = FauxtonAPI.View.extend({
- template: "addons/logs/templates/dashboard",
-
- initialize: function (options) {
- this.refreshTime = options.refreshTime || 5000;
-
- Log.events.on("log:filter", this.filterLogs, this);
- Log.events.on("log:remove", this.removeFilterLogs, this);
-
- this.filters = [];
-
- this.collection.on("add", function () {
- this.render();
- }, this);
- },
-
- establish: function () {
- return [this.collection.fetch()];
- },
-
- serialize: function () {
- var collection = new Log.Collection(this.createFilteredCollection());
-
- return {
- days: collection.sortLogsIntoDays()
- };
- },
-
- afterRender: function () {
- this.startRefreshInterval();
- },
-
- cleanup: function () {
- this.stopRefreshInterval();
- },
-
- filterLogs: function (filter) {
- this.filters.push(filter);
- this.render();
- },
-
- createFilteredCollection: function () {
- var that = this;
-
- return _.reduce(this.filters, function (logs, filter) {
-
- return _.filter(logs, function (log) {
- var match = false;
-
- _.each(log, function (value) {
- if (value.toString().match(new RegExp(filter))) {
- match = true;
- }
- });
- return match;
- });
-
-
- }, this.collection.toJSON(), this);
-
- },
-
- removeFilterLogs: function (filter) {
- this.filters.splice(this.filters.indexOf(filter), 1);
- this.render();
- },
-
- startRefreshInterval: function () {
- var collection = this.collection;
-
- // Interval already set
- if (this.intervalId) { return ; }
-
- this.intervalId = setInterval(function () {
- collection.fetch();
- }, this.refreshTime);
-
- },
-
- stopRefreshInterval: function () {
- clearInterval(this.intervalId);
- }
- });
-
- Log.Views.Sidebar = FauxtonAPI.View.extend({
- template: "addons/logs/templates/sidebar",
-
- initialize: function (options) {
- this.setView(".js-filter", new Components.FilterView({
- eventListener: Log.events,
- eventNamespace: "log"
- }));
- }
- });
-
- return Log;
-
-});
diff --git a/src/fauxton/app/addons/logs/routes.js b/src/fauxton/app/addons/logs/routes.js
deleted file mode 100644
index ce6522bde..000000000
--- a/src/fauxton/app/addons/logs/routes.js
+++ /dev/null
@@ -1,58 +0,0 @@
-// 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.
-
-define([
- "app",
-
- "api",
-
- // Modules
- "addons/logs/resources"
-],
-
-function(app, FauxtonAPI, Log) {
-
- var LogRouteObject = FauxtonAPI.RouteObject.extend({
- layout: "with_sidebar",
-
- crumbs: [
- {"name": "Logs", "link": "_log"}
- ],
-
- routes: {
- "_log": "showLog"
- },
-
- selectedHeader: "Log",
-
- roles: ["_admin"],
-
- apiUrl: function() {
- return [this.logs.url(), this.logs.documentation];
- },
-
- initialize: function () {
- this.logs = new Log.Collection();
- this.setView("#sidebar-content", new Log.Views.Sidebar({}));
- },
-
- showLog: function () {
- this.setView("#dashboard-content", new Log.Views.View({collection: this.logs}));
- }
- });
-
- Log.RouteObjects = [LogRouteObject];
-
- return Log;
-
-});
-
diff --git a/src/fauxton/app/addons/logs/templates/dashboard.html b/src/fauxton/app/addons/logs/templates/dashboard.html
deleted file mode 100644
index 855da37ed..000000000
--- a/src/fauxton/app/addons/logs/templates/dashboard.html
+++ /dev/null
@@ -1,50 +0,0 @@
-<!--
-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 class="logs">
- <h2>CouchDB Logs</h2>
- <table class="table table-bordered log-table">
- <thead>
- <tr>
- <th class="time">Date</th>
- <th class="level">Log Value</th>
- <th class="pid">Pid</th>
- <th class="args">Url</th>
- </tr>
- </thead>
-
- <tbody>
- <% _.forEach(days, function (logs, date) { %>
- <tr><td class="day" colspan="4"><%= date %></td></tr>
- <% _.forEach(logs, function (log) { %>
- <tr class="<%= log.logLevel() %>">
- <td>
- <%= log.time() %>
- </td>
- <td>
- <%= log.logLevel() %>
- </td>
- <td class="pid">
- <%= log.pid() %>
- </td>
- <td class="args">
- <!-- TODO: split the line, maybe put method in it's own column -->
- <%= log.args() %>
- </td>
- </tr>
- <% }); %>
- <% }); %>
- </tbody>
- </table>
-</div>
diff --git a/src/fauxton/app/addons/logs/templates/sidebar.html b/src/fauxton/app/addons/logs/templates/sidebar.html
deleted file mode 100644
index b9116f11a..000000000
--- a/src/fauxton/app/addons/logs/templates/sidebar.html
+++ /dev/null
@@ -1,18 +0,0 @@
-<!--
-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-sidebar">
- <header>Log Filter</header>
- <div class="js-filter"></div>
-</div>
diff --git a/src/fauxton/app/addons/logs/tests/baseSpec.js b/src/fauxton/app/addons/logs/tests/baseSpec.js
deleted file mode 100644
index 621cc9b18..000000000
--- a/src/fauxton/app/addons/logs/tests/baseSpec.js
+++ /dev/null
@@ -1,38 +0,0 @@
-// 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.
-define([
- 'addons/logs/base',
- 'chai'
-], function (Log, chai) {
- var expect = chai.expect;
-
- describe('Logs Addon', function(){
-
- describe('Log Model', function () {
- var log;
-
- beforeEach(function () {
- log = new Log.Model({
- log_level: 'DEBUG',
- pid: '1234',
- args: 'testing 123',
- date: (new Date()).toString()
- });
- });
-
- it('should have a log level', function () {
- expect(log.logLevel()).to.equal('DEBUG');
- });
-
- });
- });
-});
diff --git a/src/fauxton/app/addons/logs/tests/resourcesSpec.js b/src/fauxton/app/addons/logs/tests/resourcesSpec.js
deleted file mode 100644
index 916dc91ab..000000000
--- a/src/fauxton/app/addons/logs/tests/resourcesSpec.js
+++ /dev/null
@@ -1,117 +0,0 @@
-// 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.
-
-define([
- 'addons/logs/resources',
- 'testUtils'
-], function (Log, testUtils) {
- var assert = testUtils.assert,
- ViewSandbox = testUtils.ViewSandbox;
-
- describe('Logs Resources', function () {
-
- describe('Log Parser', function () {
- it('parses GET messages', function () {
- var parsedLog,
- collection,
- log = '[Sat, 12 Apr 2014 13:02:58 GMT] [info] [<0.3097.2>] 127.0.0.1 - - GET /_session 200\n' +
- '[Sat, 12 Apr 2014 13:02:58 GMT] [info] [<0.3098.2>] 127.0.0.1 - - GET /_session 200\n' +
- '[Sat, 12 Apr 2014 13:02:58 GMT] [info] [<0.3099.2>] 127.0.0.1 - - GET / 200\n';
-
- collection = new Log.Collection();
- parsedLog = collection.parse(log);
- assert.equal(parsedLog[0].date, 'Sat, 12 Apr 2014 13:02:58 GMT');
- assert.equal(parsedLog[0].args, '127.0.0.1 - - GET / 200');
- });
-
- it('parses GET messages with erlang errors', function () {
- var parsedLog,
- collection,
- log = '[Sat, 12 Apr 2014 13:14:15 GMT] [info] [<0.9491.2>] Retrying GET to http://176.9.4.195/registry/genstatic?revs=true&open_revs=%5B%224-a9be203658a59fd2116ae9acbd10f0de%22%5D&latest=true in 1.0 seconds due to error {error,\n' +
- ' {error,\n' +
- ' connection_closing}}\n' +
- '[Sat, 12 Apr 2014 13:14:15 GMT] [error] [<0.9499.2>] Replicator, request GET to "http://176.9.4.195/registry/google-openid?revs=true&open_revs=%5B%2219-380884ba97e3d6fc48c8c7db3dc0e91b%22%5D&latest=true" failed due to error {error,connection_closing}\n' +
- '[Sat, 12 Apr 2014 13:14:15 GMT] [info] [<0.9497.2>] Retrying GET to http://176.9.4.195/registry/google-openid?revs=true&open_revs=%5B%2219-380884ba97e3d6fc48c8c7db3dc0e91b%22%5D&latest=true in 1.0 seconds due to error {error,\n' +
- ' {error,\n' +
- ' connection_closing}}\n' +
- '[Sat, 12 Apr 2014 13:14:15 GMT] [error] [<0.9507.2>] Replicator, request GET to "http://176.9.4.195/registry/google-openid?revs=true&open_revs=%5B%224-c8ba4809e2cacc1635f8887ec0d8d49a%22%5D&latest=true" failed due to error {error,connection_closing}\n' +
- '[Sat, 12 Apr 2014 13:14:15 GMT] [info] [<0.9505.2>] Retrying GET to http://176.9.4.195/registry/google-openid?revs=true&open_revs=%5B%224-c8ba4809e2cacc1635f8887ec0d8d49a%22%5D&latest=true in 1.0 seconds due to error {error,\n' +
- ' {error,\n' +
- ' connection_closing}}\n';
-
- collection = new Log.Collection();
- parsedLog = collection.parse(log);
- assert.equal(parsedLog[1].date, 'Sat, 12 Apr 2014 13:14:15 GMT');
- assert.equal(parsedLog[1].args, 'Replicator, request GET to "http://176.9.4.195/registry/google-openid?revs=true&open_revs=%5B%224-c8ba4809e2cacc1635f8887ec0d8d49a%22%5D&latest=true" failed due to error {error,connection_closing}');
- assert.equal(parsedLog[2].args, 'Retrying GET to http://176.9.4.195/registry/google-openid?revs=true&open_revs=%5B%2219-380884ba97e3d6fc48c8c7db3dc0e91b%22%5D&latest=true in 1.0 seconds due to error {error,{error,connection_closing}}');
- });
- });
-
- describe('uses a heading for each date (COUCHDB-2136)', function () {
- var collection,
- view;
-
- beforeEach(function () {
- collection = new Log.Collection([
- new Log.Model({
- date: new Date('Fri Apr 19 2014 12:06:01 GMT+0200 (CEST)'),
- log_level: 'info',
- pid: 1337,
- args: 'ente ente'
- }),
- new Log.Model({
- date: new Date('Fri Apr 18 2014 12:06:01 GMT+0200 (CEST)'),
- log_level: 'info',
- pid: 1337,
- args: 'ente ente'
- }),
- new Log.Model({
- date: new Date('Thu Apr 17 2014 12:06:01 GMT+0200 (CEST)'),
- log_level: 'info',
- pid: 1337,
- args: 'ente ente'
- }),
- new Log.Model({
- date: new Date('Thu Apr 16 2014 12:06:01 GMT+0200 (CEST)'),
- log_level: 'info',
- pid: 1337,
- args: 'ente ente'
- })
- ]);
-
- });
-
- it('sorts the data into an object', function () {
- var sortedCollection = collection.sortLogsIntoDays();
-
- assert.property(sortedCollection, 'Apr 18');
- assert.property(sortedCollection, 'Apr 17');
- });
-
- it('creates headers with dates', function () {
- var titles = [],
- viewSandbox,
- view;
-
- view = new Log.Views.View({collection: collection});
- viewSandbox = new ViewSandbox();
- viewSandbox.renderView(view);
-
- view.$('td[colspan="4"]').each(function (i, elem) {
- titles.push($(elem).text());
- });
- assert.include(titles, 'Apr 18');
- assert.include(titles, 'Apr 17');
- });
- });
- });
-});
diff --git a/src/fauxton/assets/less/fauxton.less b/src/fauxton/assets/less/fauxton.less
index 177cadc6f..fc9290967 100644
--- a/src/fauxton/assets/less/fauxton.less
+++ b/src/fauxton/assets/less/fauxton.less
@@ -859,12 +859,6 @@ form.view-query-update, form.view-query-save {
max-width: 100%;
}
-/*logs*/
-#log-sidebar{
- padding: 20px;
-}
-
-
/*documents and databases */
.view.show{
color: @fontGrey;
diff --git a/src/fauxton/settings.json.default b/src/fauxton/settings.json.default
index eedf2f188..bc5a6174e 100644
--- a/src/fauxton/settings.json.default
+++ b/src/fauxton/settings.json.default
@@ -6,7 +6,6 @@
{ "name": "pouchdb" },
{ "name": "activetasks" },
{ "name": "config" },
- { "name": "logs" },
{ "name": "stats" },
{ "name": "replication" },
{ "name": "plugins" },
diff --git a/src/fauxton/settings.json.dev b/src/fauxton/settings.json.dev
index d354c29ff..62cd1e73c 100644
--- a/src/fauxton/settings.json.dev
+++ b/src/fauxton/settings.json.dev
@@ -6,7 +6,6 @@
{ "name": "pouchdb" },
{ "name": "activetasks" },
{ "name": "config" },
- { "name": "logs" },
{ "name": "stats" },
{ "name": "replication" },
{ "name": "plugins" },