couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From j..@apache.org
Subject [2/8] git commit: Open the JS log file if it is different from the primary log file
Date Mon, 11 Feb 2013 05:43:17 GMT
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/a94ff599
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/a94ff599
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/a94ff599

Branch: refs/heads/1677-feature-query_server_log_file
Commit: a94ff5990ce4afd2ab2a2190f7690cd310452d30
Parents: a8627f1
Author: Jason Smith (work) <jhs@iriscouch.com>
Authored: Mon Feb 11 04:10:35 2013 +0000
Committer: Jason Smith (work) <jhs@iriscouch.com>
Committed: Mon Feb 11 04:17:50 2013 +0000

----------------------------------------------------------------------
 src/couchdb/couch_log.erl |   29 ++++++++++++++++++++++++++++-
 1 files changed, 28 insertions(+), 1 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb/blob/a94ff599/src/couchdb/couch_log.erl
----------------------------------------------------------------------
diff --git a/src/couchdb/couch_log.erl b/src/couchdb/couch_log.erl
index cd4bbbb..2e9a351 100644
--- a/src/couchdb/couch_log.erl
+++ b/src/couchdb/couch_log.erl
@@ -31,6 +31,7 @@
 
 -record(state, {
     fd,
+    query_srv_fd,
     level,
     sasl
 }).
@@ -78,6 +79,8 @@ init([]) ->
     ok = couch_config:register(
         fun("log", "file") ->
             ?MODULE:stop();
+        ("log", "query_server_file") ->
+            ?MODULE:stop();
         ("log", "level") ->
             ?MODULE:stop();
         ("log", "include_sasl") ->
@@ -101,10 +104,34 @@ init([]) ->
         ets:insert(?MODULE, {Module, ModuleLevelInteger})
     end, LevelByModule),
 
+    QuerySrvFile = case couch_config:get("log", "query_server_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} ->
-        {ok, #state{fd = Fd, level = Level, sasl = Sasl}};
+        case QuerySrvFile of
+        Filename ->
+            {ok, #state{fd = Fd, query_srv_fd = Fd, level = Level, sasl = Sasl}};
+        _ ->
+            case file:open(QuerySrvFile, [append]) of
+            {ok, QueryFd} ->
+                {ok, #state{fd = Fd, query_srv_fd = QueryFd, level = Level, sasl = Sasl}};
+            {error, Reason} ->
+                ReasonStr = file:format_error(Reason),
+                io:format("Error opening JavaScript log file ~s: ~s", [QuerySrvFile, ReasonStr]),
+                {stop, {error, ReasonStr, QuerySrvFile}}
+            end
+        end;
     {error, Reason} ->
         ReasonStr = file:format_error(Reason),
         io:format("Error opening log file ~s: ~s", [Filename, ReasonStr]),


Mime
View raw message