couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject [17/20] git commit: The view log file is relative to the log directory, unless it is absolute
Date Sat, 02 Feb 2013 15:32:18 GMT
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) <jhs@iriscouch.com>
Authored: Sat Feb 2 14:00:02 2013 +0000
Committer: Jason Smith (work) <jhs@iriscouch.com>
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} ->


Mime
View raw message