From 2d33a134150e85b195529ce17446f225b881cf9d Mon Sep 17 00:00:00 2001 From: "John R. Daily" Date: Thu, 12 Mar 2015 10:39:19 -0400 Subject: [PATCH] Clarify that "event" in this module is what we are now calling a "sink" --- src/lager_handler_watcher.erl | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/src/lager_handler_watcher.erl b/src/lager_handler_watcher.erl index 24498a4..af0844d 100644 --- a/src/lager_handler_watcher.erl +++ b/src/lager_handler_watcher.erl @@ -38,18 +38,18 @@ -record(state, { module :: atom(), config :: any(), - event :: pid() | atom() + sink :: pid() | atom() }). -start_link(Event, Module, Config) -> - gen_server:start_link(?MODULE, [Event, Module, Config], []). +start_link(Sink, Module, Config) -> + gen_server:start_link(?MODULE, [Sink, Module, Config], []). -start(Event, Module, Config) -> - gen_server:start(?MODULE, [Event, Module, Config], []). +start(Sink, Module, Config) -> + gen_server:start(?MODULE, [Sink, Module, Config], []). -init([Event, Module, Config]) -> - install_handler(Event, Module, Config), - {ok, #state{event=Event, module=Module, config=Config}}. +init([Sink, Module, Config]) -> + install_handler(Sink, Module, Config), + {ok, #state{sink=Sink, module=Module, config=Config}}. handle_call(_Call, _From, State) -> {reply, ok, State}. @@ -62,18 +62,18 @@ handle_info({gen_event_EXIT, Module, normal}, #state{module=Module} = State) -> handle_info({gen_event_EXIT, Module, shutdown}, #state{module=Module} = State) -> {stop, normal, State}; handle_info({gen_event_EXIT, Module, Reason}, #state{module=Module, - config=Config, event=Event} = State) -> + config=Config, sink=Sink} = State) -> case lager:log(error, self(), "Lager event handler ~p exited with reason ~s", [Module, error_logger_lager_h:format_reason(Reason)]) of ok -> - install_handler(Event, Module, Config); + install_handler(Sink, Module, Config); {error, _} -> %% lager is not working, so installing a handler won't work ok end, {noreply, State}; -handle_info(reinstall_handler, #state{module=Module, config=Config, event=Event} = State) -> - install_handler(Event, Module, Config), +handle_info(reinstall_handler, #state{module=Module, config=Config, sink=Sink} = State) -> + install_handler(Sink, Module, Config), {noreply, State}; handle_info(stop, State) -> {stop, normal, State}; @@ -88,22 +88,22 @@ code_change(_OldVsn, State, _Extra) -> %% internal -install_handler(Event, Module, Config) -> - case gen_event:add_sup_handler(Event, Module, Config) of +install_handler(Sink, Module, Config) -> + case gen_event:add_sup_handler(Sink, Module, Config) of ok -> - ?INT_LOG(debug, "Lager installed handler ~p into ~p", [Module, Event]), + ?INT_LOG(debug, "Lager installed handler ~p into ~p", [Module, Sink]), lager:update_loglevel_config(), ok; {error, {fatal, Reason}} -> ?INT_LOG(error, "Lager fatally failed to install handler ~p into" - " ~p, NOT retrying: ~p", [Module, Event, Reason]), + " ~p, NOT retrying: ~p", [Module, Sink, Reason]), %% tell ourselves to stop self() ! stop, ok; Error -> %% try to reinstall it later ?INT_LOG(error, "Lager failed to install handler ~p into" - " ~p, retrying later : ~p", [Module, Event, Error]), + " ~p, retrying later : ~p", [Module, Sink, Error]), erlang:send_after(5000, self(), reinstall_handler), ok end.