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 56128EFC7 for ; Sat, 2 Feb 2013 15:32:23 +0000 (UTC) Received: (qmail 57548 invoked by uid 500); 2 Feb 2013 15:32:21 -0000 Delivered-To: apmail-couchdb-commits-archive@couchdb.apache.org Received: (qmail 57453 invoked by uid 500); 2 Feb 2013 15:32:21 -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 57073 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 EED9B82942B; Sat, 2 Feb 2013 15:32:18 +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: [17/20] git commit: The view log file is relative to the log directory, unless it is absolute Message-Id: <20130202153218.EED9B82942B@tyr.zones.apache.org> Date: Sat, 2 Feb 2013 15:32:18 +0000 (UTC) The view log file is relative to the log directory, unless it is absolute Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/b32ee45e Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/b32ee45e Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/b32ee45e Branch: refs/heads/console_log Commit: b32ee45e2b592960ab873a724463007c7f3e0e8c Parents: 04c89cc Author: Jason Smith (work) Authored: Sat Feb 2 14:00:02 2013 +0000 Committer: Jason Smith (work) Committed: Sat Feb 2 14:16:12 2013 +0000 ---------------------------------------------------------------------- src/couchdb/couch_log.erl | 25 ++++++++++++++++++------- 1 files changed, 18 insertions(+), 7 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb/blob/b32ee45e/src/couchdb/couch_log.erl ---------------------------------------------------------------------- diff --git a/src/couchdb/couch_log.erl b/src/couchdb/couch_log.erl index 7e2f1c2..7d7ed0a 100644 --- a/src/couchdb/couch_log.erl +++ b/src/couchdb/couch_log.erl @@ -90,7 +90,6 @@ 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"), @@ -105,20 +104,32 @@ init([]) -> ets:insert(?MODULE, {Module, ModuleLevelInteger}) end, LevelByModule), + ViewFilename = case couch_config:get("log", "view_file", Filename) of + Filename -> + Filename; + OtherFilename -> + case filename:pathtype(OtherFilename) of + relative -> + LogDir = filename:dirname(Filename), + filename:join(LogDir, OtherFilename); + _ -> + OtherFilename + end + end, case file:open(Filename, [append]) of {ok, Fd} -> - case JsFilename of + case ViewFilename 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}}; + case file:open(ViewFilename, [append]) of + {ok, ViewFd} -> + {ok, #state{fd = Fd, view_fd = ViewFd, 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}} + io:format("Error opening JavaScript log file ~s: ~s", [ViewFilename, ReasonStr]), + {stop, {error, ReasonStr, ViewFilename}} end end; {error, Reason} ->