summaryrefslogtreecommitdiff
path: root/src/couchdb/couch_log.erl
diff options
context:
space:
mode:
authorJan Lehnardt <jan@apache.org>2008-08-20 13:55:41 +0000
committerJan Lehnardt <jan@apache.org>2008-08-20 13:55:41 +0000
commit2bc4be3dbf9e8ea3b67c62f2d99087ff4b43c17b (patch)
tree9a961f6f3fb0acbd9d34abef40492bbe95cc3d94 /src/couchdb/couch_log.erl
parentad6fd47a1f13e8d09eb5864c50e102825e28b75c (diff)
Merge runtimeconfig branch back into trunk
git-svn-id: https://svn.apache.org/repos/asf/incubator/couchdb/trunk@687336 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src/couchdb/couch_log.erl')
-rw-r--r--src/couchdb/couch_log.erl24
1 files changed, 19 insertions, 5 deletions
diff --git a/src/couchdb/couch_log.erl b/src/couchdb/couch_log.erl
index 95ddc47f..0c2f9df7 100644
--- a/src/couchdb/couch_log.erl
+++ b/src/couchdb/couch_log.erl
@@ -13,7 +13,7 @@
-module(couch_log).
-behaviour(gen_event).
--export([start_link/2,stop/0]).
+-export([start_link/0,stop/0]).
-export([debug_on/0,info_on/0,get_level/0,get_level_integer/0, set_level/1]).
-export([init/1, handle_event/2, terminate/2, code_change/3, handle_info/2, handle_call/2]).
@@ -34,15 +34,29 @@ level_atom(?LEVEL_DEBUG) -> debug;
level_atom(?LEVEL_TMI) -> tmi.
-start_link(Filename, Level) ->
- couch_event_sup:start_link({local, couch_log}, error_logger, couch_log, {Filename, Level}).
+start_link() ->
+ couch_event_sup:start_link({local, couch_log}, error_logger, couch_log, []).
stop() ->
couch_event_sup:stop(couch_log).
-init({Filename, Level}) ->
+init([]) ->
+ % read config and register for configuration changes
+
+ % just stop if one of the config settings change. couch_server_sup
+ % will restart us and then we will pick up the new settings.
+ ok = couch_config:register(
+ fun({"Log", "File"}) ->
+ ?MODULE:stop();
+ ({"Log", "Level"}) ->
+ ?MODULE:stop()
+ end),
+
+ Filename = couch_config:get({"Log", "File"}, "couchdb.log"),
+ Level = couch_config:get({"Log", "Level"},"info"),
+
{ok, Fd} = file:open(Filename, [append]),
- {ok, {Fd, level_integer(Level)}}.
+ {ok, {Fd, level_integer(list_to_atom(Level))}}.
debug_on() ->
get_level_integer() =< ?LEVEL_DEBUG.