Return-Path: X-Original-To: apmail-couchdb-commits-archive@www.apache.org Delivered-To: apmail-couchdb-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id C54F111F8F for ; Mon, 28 Apr 2014 12:43:12 +0000 (UTC) Received: (qmail 57622 invoked by uid 500); 28 Apr 2014 12:42:34 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 56277 invoked by uid 500); 28 Apr 2014 12:41:56 -0000 Mailing-List: contact commits-help@couchdb.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@couchdb.apache.org Delivered-To: mailing list commits@couchdb.apache.org Received: (qmail 55236 invoked by uid 99); 28 Apr 2014 12:41:37 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 28 Apr 2014 12:41:37 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id A91F69959D9; Mon, 28 Apr 2014 12:41:35 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: dch@apache.org To: commits@couchdb.apache.org Date: Mon, 28 Apr 2014 12:42:07 -0000 Message-Id: <86360c8ea4264cd9909b479af0ac32d8@git.apache.org> In-Reply-To: <8eb79567b3b740e8a9c3ed07ee666767@git.apache.org> References: <8eb79567b3b740e8a9c3ed07ee666767@git.apache.org> X-Mailer: ASF-Git Admin Mailer Subject: [34/50] couchdb commit: updated refs/heads/2200-feature-support-erlang-17.0 to c81eb6d 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/2200-feature-support-erlang-17.0 Commit: e3239f195e6058bfb48878e393a0334383b08474 Parents: 174e759 Author: Robert Kowalski Authored: Sat Apr 12 15:34:10 2014 +0200 Committer: suelockwood 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}}'); }); }); });