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/02 16:32:19 UTC
[14/20] git commit: Open the JS log file if it is different from the
primary log file
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) <jh...@iriscouch.com>
Authored: Sat Feb 2 13:45:50 2013 +0000
Committer: Jason Smith (work) <jh...@iriscouch.com>
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]),