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 B139FEFD5 for ; Sat, 2 Feb 2013 15:32:25 +0000 (UTC) Received: (qmail 58415 invoked by uid 500); 2 Feb 2013 15:32:23 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 57815 invoked by uid 500); 2 Feb 2013 15:32:22 -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 57117 invoked by uid 99); 2 Feb 2013 15:32:19 -0000 Received: from tyr.zones.apache.org (HELO tyr.zones.apache.org) (140.211.11.114) by apache.org (qpsmtpd/0.29) with ESMTP; Sat, 02 Feb 2013 15:32:19 +0000 Received: by tyr.zones.apache.org (Postfix, from userid 65534) id 0BA8E829431; Sat, 2 Feb 2013 15:32:19 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: jhs@apache.org To: commits@couchdb.apache.org X-Mailer: ASF-Git Admin Mailer Subject: [14/20] git commit: Open the JS log file if it is different from the primary log file Message-Id: <20130202153219.0BA8E829431@tyr.zones.apache.org> Date: Sat, 2 Feb 2013 15:32:19 +0000 (UTC) Open the JS log file if it is different from the primary log file Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/7feb3052 Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/7feb3052 Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/7feb3052 Branch: refs/heads/console_log Commit: 7feb30527af0e0d6c780d9050401b7f2f6323c0f Parents: e68d74a Author: Jason Smith (work) Authored: Sat Feb 2 13:45:50 2013 +0000 Committer: Jason Smith (work) Committed: Sat Feb 2 14:16:12 2013 +0000 ---------------------------------------------------------------------- src/couchdb/couch_log.erl | 18 +++++++++++++++++- 1 files changed, 17 insertions(+), 1 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb/blob/7feb3052/src/couchdb/couch_log.erl ---------------------------------------------------------------------- diff --git a/src/couchdb/couch_log.erl b/src/couchdb/couch_log.erl index cd4bbbb..7e2f1c2 100644 --- a/src/couchdb/couch_log.erl +++ b/src/couchdb/couch_log.erl @@ -31,6 +31,7 @@ -record(state, { fd, + view_fd, level, sasl }). @@ -78,6 +79,8 @@ init([]) -> ok = couch_config:register( fun("log", "file") -> ?MODULE:stop(); + ("log", "view_file") -> + ?MODULE:stop(); ("log", "level") -> ?MODULE:stop(); ("log", "include_sasl") -> @@ -87,6 +90,7 @@ init([]) -> end), Filename = couch_config:get("log", "file", "couchdb.log"), + JsFilename = couch_config:get("log", "view_file", Filename), Level = level_integer(list_to_atom(couch_config:get("log", "level", "info"))), Sasl = couch_config:get("log", "include_sasl", "true") =:= "true", LevelByModule = couch_config:get("log_level_by_module"), @@ -104,7 +108,19 @@ init([]) -> case file:open(Filename, [append]) of {ok, Fd} -> - {ok, #state{fd = Fd, level = Level, sasl = Sasl}}; + case JsFilename of + Filename -> + {ok, #state{fd = Fd, view_fd = Fd, level = Level, sasl = Sasl}}; + _ -> + case file:open(JsFilename, [append]) of + {ok, JsFd} -> + {ok, #state{fd = Fd, view_fd = JsFd, level = Level, sasl = Sasl}}; + {error, Reason} -> + ReasonStr = file:format_error(Reason), + io:format("Error opening JavaScript log file ~s: ~s", [JsFilename, ReasonStr]), + {stop, {error, ReasonStr, JsFilename}} + end + end; {error, Reason} -> ReasonStr = file:format_error(Reason), io:format("Error opening log file ~s: ~s", [Filename, ReasonStr]),