Repository: couchdb Updated Branches: refs/heads/master 174e7596e -> e3239f195
Fauxton: do not slice off the error text from erlang errors As the erlang errors contain two linebreaks, and the parsing function is using linebreaks to separate the messages, the content was sliced off, which looked like there would not be enough space for the message. In fact it got lost during the parsing. This tries to normalize the data before and after the parsing, it removes the linebreaks of the erlang errors so it is parsed right. As the other spaces are no &nspb;-entities it does not hurt that the are removed. Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/e3239f19 Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/e3239f19 Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/e3239f19 Branch: refs/heads/master Commit: e3239f195e6058bfb48878e393a0334383b08474 Parents: 174e759 Author: Robert Kowalski <[email protected]> Authored: Sat Apr 12 15:34:10 2014 +0200 Committer: suelockwood <[email protected]> Committed: Thu Apr 17 16:17:36 2014 -0400 ---------------------------------------------------------------------- src/fauxton/app/addons/logs/resources.js | 5 +- .../app/addons/logs/tests/resourcesSpec.js | 48 ++++++++++++++------ 2 files changed, 37 insertions(+), 16 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb/blob/e3239f19/src/fauxton/app/addons/logs/resources.js ---------------------------------------------------------------------- diff --git a/src/fauxton/app/addons/logs/resources.js b/src/fauxton/app/addons/logs/resources.js index c285395..6082fcd 100644 --- a/src/fauxton/app/addons/logs/resources.js +++ b/src/fauxton/app/addons/logs/resources.js @@ -67,7 +67,8 @@ function (app, FauxtonAPI, Backbone, d3) { }, parse: function (resp) { - var lines = resp.split(/\n/); + resp = resp.replace(/\n\s/g, ''); + var lines = resp.split(/\n/); return _.foldr(lines, function (acc, logLine) { var match = logLine.match(/^\[(.*?)\]\s\[(.*?)\]\s\[(.*?)\]\s(.*)/); @@ -77,7 +78,7 @@ function (app, FauxtonAPI, Backbone, d3) { date: match[1], log_level: match[2], pid: match[3], - args: match[4] + args: match[4].replace(/\s\s+/g, '') }); return acc; http://git-wip-us.apache.org/repos/asf/couchdb/blob/e3239f19/src/fauxton/app/addons/logs/tests/resourcesSpec.js ---------------------------------------------------------------------- diff --git a/src/fauxton/app/addons/logs/tests/resourcesSpec.js b/src/fauxton/app/addons/logs/tests/resourcesSpec.js index d67c677..5bdd339 100644 --- a/src/fauxton/app/addons/logs/tests/resourcesSpec.js +++ b/src/fauxton/app/addons/logs/tests/resourcesSpec.js @@ -16,22 +16,42 @@ define([ ], function (Log, testUtils) { var assert = testUtils.assert; - describe('Log Resources', function () { + describe('Logs Resources', function () { - describe('Date Formatter', function () { - it('adds leading zeros to minutes', function () { - var model; + 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'; - model = new Log.Model({ - date: 'Sat, 12 Apr 2014 15:04:01 GMT', - log_level: 'info', - pid: '123', - args: 'ente ente' - }); - // timezones with daylightsaving in JS are hard - // and we use the current local time here - // so do not test for hours and the exact day - assert.ok(/Apr \d\d \d\d:04:01/.test(model.date())); + 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}}'); }); }); });
