summaryrefslogtreecommitdiff
path: root/src/couch_log/src/couch_log_server.erl
diff options
context:
space:
mode:
Diffstat (limited to 'src/couch_log/src/couch_log_server.erl')
-rw-r--r--src/couch_log/src/couch_log_server.erl27
1 files changed, 6 insertions, 21 deletions
diff --git a/src/couch_log/src/couch_log_server.erl b/src/couch_log/src/couch_log_server.erl
index 8432b9aa3..05cf92a75 100644
--- a/src/couch_log/src/couch_log_server.erl
+++ b/src/couch_log/src/couch_log_server.erl
@@ -13,7 +13,6 @@
-module(couch_log_server).
-behavior(gen_server).
-
-export([
start_link/0,
reconfigure/0,
@@ -21,42 +20,35 @@
]).
-export([
- init/1,
- terminate/2,
- handle_call/3,
- handle_cast/2,
- handle_info/2,
- code_change/3
+ init/1,
+ terminate/2,
+ handle_call/3,
+ handle_cast/2,
+ handle_info/2,
+ code_change/3
]).
-
-include("couch_log.hrl").
-
-record(st, {
writer
}).
-
-ifdef(TEST).
-define(SEND(Entry), gen_server:call(?MODULE, {log, Entry})).
-else.
-define(SEND(Entry), gen_server:cast(?MODULE, {log, Entry})).
-endif.
-
start_link() ->
gen_server:start_link({local, ?MODULE}, ?MODULE, [], []).
-
reconfigure() ->
gen_server:call(?MODULE, reconfigure).
-
log(Entry) ->
?SEND(Entry).
-
init(_) ->
couch_util:set_mqd_off_heap(?MODULE),
process_flag(trap_exit, true),
@@ -64,17 +56,14 @@ init(_) ->
writer = couch_log_writer:init()
}}.
-
terminate(Reason, St) ->
ok = couch_log_writer:terminate(Reason, St#st.writer).
-
handle_call(reconfigure, _From, St) ->
ok = couch_log_writer:terminate(reconfiguring, St#st.writer),
{reply, ok, St#st{
writer = couch_log_writer:init()
}};
-
handle_call({log, Entry}, _From, St) ->
% We re-check if we should log here in case an operator
% adjusted the log level and then realized it was a bad
@@ -86,22 +75,18 @@ handle_call({log, Entry}, _From, St) ->
false ->
{reply, ok, St}
end;
-
handle_call(Ignore, From, St) ->
Args = [?MODULE, Ignore],
Entry = couch_log_formatter:format(error, ?MODULE, "~s ignored ~p", Args),
handle_call({log, Entry}, From, St).
-
handle_cast(Msg, St) ->
{reply, ok, NewSt} = handle_call(Msg, nil, St),
{noreply, NewSt}.
-
handle_info(Msg, St) ->
{reply, ok, NewSt} = handle_call(Msg, nil, St),
{noreply, NewSt}.
-
code_change(_Vsn, St, _Extra) ->
{ok, St}.