Commit 75a50886 authored by Andrew Thompson's avatar Andrew Thompson
Browse files

Make the file backend clean up on terminate

Showing with 10 additions and 3 deletions
+10 -3
......@@ -33,7 +33,8 @@ start_link() ->
%application:start(riak_err),
Handlers = case application:get_env(lager, handlers) of
undefined ->
[{lager_console_backend, [info]}];
[{lager_console_backend, [info]},
{lager_file_backend, [{"error.log", error}, {"console.log", info}]}];
Val ->
Val
end,
......@@ -91,6 +92,7 @@ handle_info(Info, State) ->
{noreply, State}.
terminate(_Reason, _State) ->
gen_event:stop(lager_event),
ok.
code_change(_OldVsn, State, _Extra) ->
......
......@@ -67,8 +67,13 @@ handle_event(_Event, State) ->
handle_info(_Info, State) ->
{ok, State}.
terminate(_Reason, _State) ->
ok.
terminate(_Reason, State) ->
io:format("lager file handler exiting~n"),
%% flush and close any file handles
lists:foreach(
fun({_, _, FD, _}) -> file:datasync(FD), file:close(FD);
(_) -> ok
end, State#state.files).
code_change(_OldVsn, State, _Extra) ->
{ok, State}.
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment