Description and logging
This commit is contained in:
parent
ae72db2769
commit
5c920823bb
|
@ -1,5 +1,5 @@
|
|||
{application, log_monitor,
|
||||
[{description, "An OTP application"},
|
||||
[{description, "Log monitoring application"},
|
||||
{vsn, "0.1.0"},
|
||||
{registered, []},
|
||||
{mod, { log_monitor_app, []}},
|
||||
|
|
|
@ -12,8 +12,8 @@ init([]) ->
|
|||
handle_info({error, File, Text}, []) ->
|
||||
case send_email(File, Text) of
|
||||
{error, Reason, Message} ->
|
||||
io:format("Error sending email: ~s ~p~n", [Reason, Message]);
|
||||
_ -> io:format("Mail sent~n", [])
|
||||
error_logger:error_msg("Error sending email: ~s ~p~n", [Reason, Message]);
|
||||
_ -> ok
|
||||
end,
|
||||
{noreply, []}.
|
||||
|
||||
|
@ -36,7 +36,7 @@ send_email(File, Text) ->
|
|||
Relay = proplists:get_value(relay, EmailConfig),
|
||||
Username = proplists:get_value(username, EmailConfig),
|
||||
Password = proplists:get_value(password, EmailConfig),
|
||||
io:format("Send Email for file ~s with text: ~n~s~n", [File, Text]),
|
||||
error_logger:info_report("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])},
|
||||
[{relay, Relay}, {username, Username}, {password, Password}]).
|
||||
|
|
|
@ -17,7 +17,6 @@ handle_info(Msg, [SupPid, Port]) ->
|
|||
GathererPid ! {log_line, Text},
|
||||
{noreply, [SupPid, Port]};
|
||||
{Port, {exit_status, _Status}} ->
|
||||
io:format("Watcher terminated~n"),
|
||||
{stop, tail_exit, []}
|
||||
end.
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user