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