Mail info and log status update
This commit is contained in:
parent
9b13aa6cbc
commit
d3d42097d9
|
@ -33,11 +33,18 @@ init([]) ->
|
|||
{ok, #state{statuses = Statuses}}.
|
||||
|
||||
handle_info({watcher_init, File}, State = #state{statuses = Statuses}) ->
|
||||
ets:insert(Statuses, {File, active}),
|
||||
case ets:lookup(Statuses, File) of
|
||||
%% If the File has been removed, do nothing
|
||||
[] -> ok;
|
||||
_ -> ets:insert(Statuses, {File, active})
|
||||
end,
|
||||
{noreply, State};
|
||||
handle_info({watcher_terminate, File}, State = #state{statuses = Statuses}) ->
|
||||
%% TODO: do not update it if not present
|
||||
ets:insert(Statuses, {File, inactive}),
|
||||
case ets:lookup(Statuses, File) of
|
||||
%% If the File has been removed, do nothing
|
||||
[] -> ok;
|
||||
_ -> ets:insert(Statuses, {File, inactive})
|
||||
end,
|
||||
{noreply, State};
|
||||
handle_info(_Msg, State) ->
|
||||
{noreply, State}.
|
||||
|
|
|
@ -37,7 +37,7 @@ send_email(File, Text) ->
|
|||
Sender = proplists:get_value(sender, EmailConfig),
|
||||
DefaultReceiver = proplists:get_value(default_receiver, EmailConfig),
|
||||
Connection = proplists:get_value(connection, EmailConfig),
|
||||
error_logger:info_report("Sending email for file ~s with text: ~n~s~n", [File, Text]),
|
||||
error_logger:info_msg("Sending email for file ~s with text: ~n~s~n", [File, Text]),
|
||||
gen_smtp_client:send_blocking(
|
||||
{Sender, [DefaultReceiver],
|
||||
io_lib:format("Subject: Error notification\r\nFrom: Fabio\r\n\r\nLogfile: ~s~nError: ~n~s~n", [File, Text])},
|
||||
|
|
Loading…
Reference in New Issue
Block a user