You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@couchdb.apache.org by jh...@apache.org on 2013/02/11 06:43:17 UTC
[4/8] git commit: Refactor to a utility function: the code to compute
the query server logfile
Refactor to a utility function: the code to compute the query server logfile
Project: http://git-wip-us.apache.org/repos/asf/couchdb/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb/commit/a5bc5578
Tree: http://git-wip-us.apache.org/repos/asf/couchdb/tree/a5bc5578
Diff: http://git-wip-us.apache.org/repos/asf/couchdb/diff/a5bc5578
Branch: refs/heads/1677-feature-query_server_log_file
Commit: a5bc55784ca58fef31f7e5e3fccbd28bf5b89659
Parents: 87670bf
Author: Jason Smith (work) <jh...@iriscouch.com>
Authored: Mon Feb 11 05:23:32 2013 +0000
Committer: Jason Smith (work) <jh...@iriscouch.com>
Committed: Mon Feb 11 05:29:25 2013 +0000
----------------------------------------------------------------------
src/couchdb/couch_log.erl | 32 +++++++++++++++++++-------------
1 files changed, 19 insertions(+), 13 deletions(-)
----------------------------------------------------------------------
http://git-wip-us.apache.org/repos/asf/couchdb/blob/a5bc5578/src/couchdb/couch_log.erl
----------------------------------------------------------------------
diff --git a/src/couchdb/couch_log.erl b/src/couchdb/couch_log.erl
index 937cf4b..c30b67a 100644
--- a/src/couchdb/couch_log.erl
+++ b/src/couchdb/couch_log.erl
@@ -111,19 +111,7 @@ 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,
-
+ QuerySrvFile = get_abs_query_server_file(),
case file:open(Filename, [append]) of
{ok, Fd} ->
case QuerySrvFile of
@@ -265,6 +253,24 @@ get_query_server_messages(Pid, Level, Port, Message) ->
{ConsoleMsg, FileMsg, QueryFileMsg}.
+% Get the absolute path to the configured query server file. If it looks like
+% a relative path, then it is relative to the main log file's directory.
+get_abs_query_server_file() ->
+ LogFile = couch_config:get("log", "file", "couchdb.log"),
+ case couch_config:get("log", "query_server_file", LogFile) of
+ LogFile ->
+ LogFile;
+ OtherFile ->
+ case filename:pathtype(OtherFile) of
+ relative ->
+ LogDir = filename:dirname(LogFile),
+ filename:join(LogDir, OtherFile);
+ _ ->
+ OtherFile
+ end
+ end.
+
+
% Read Bytes bytes from the end of log file, jumping Offset bytes towards
% the beginning of the file first.
%