Fixed subject with first error line
This commit is contained in:
parent
dbeec61590
commit
680a5d3aed
|
@ -186,7 +186,7 @@ send_email(File, Text) ->
|
||||||
-> [DefaultReceiver];
|
-> [DefaultReceiver];
|
||||||
true -> GroupReceivers
|
true -> GroupReceivers
|
||||||
end,
|
end,
|
||||||
Subject = email_subject(RawSubject, File, lists:takewhile(fun(X) -> X =/= "\n" end, Text)),
|
Subject = email_subject(RawSubject, File, first_line(Text)),
|
||||||
error_logger:info_msg(
|
error_logger:info_msg(
|
||||||
"Sending email [~n\tSender: ~s,~n\tReceivers: ~s,~n\tSubject: ~s,~n\tFile: ~s~n]~n",
|
"Sending email [~n\tSender: ~s,~n\tReceivers: ~s,~n\tSubject: ~s,~n\tFile: ~s~n]~n",
|
||||||
[Sender, lists:join(",", Receivers), Subject, File]
|
[Sender, lists:join(",", Receivers), Subject, File]
|
||||||
|
@ -250,6 +250,9 @@ file_name_from_path(File) ->
|
||||||
{match, [_, _, Basename]} = re:run(File, "^(.*\/)?(.*)\\..*$", [{capture, all, list}]),
|
{match, [_, _, Basename]} = re:run(File, "^(.*\/)?(.*)\\..*$", [{capture, all, list}]),
|
||||||
Basename.
|
Basename.
|
||||||
|
|
||||||
|
first_line(Text) ->
|
||||||
|
lists:takewhile(fun(X) -> X =/= 10 end, Text). %% 10: newline
|
||||||
|
|
||||||
%%%===================================================================
|
%%%===================================================================
|
||||||
%%% Tests
|
%%% Tests
|
||||||
%%%===================================================================
|
%%%===================================================================
|
||||||
|
@ -274,4 +277,9 @@ file_name_from_path_test() ->
|
||||||
?assertEqual("myApp", file_name_from_path("./myApp.log")),
|
?assertEqual("myApp", file_name_from_path("./myApp.log")),
|
||||||
?assertEqual("myApp", file_name_from_path("/var/log/myApp.log")).
|
?assertEqual("myApp", file_name_from_path("/var/log/myApp.log")).
|
||||||
|
|
||||||
|
first_line_test() ->
|
||||||
|
?assertEqual("", first_line("")),
|
||||||
|
?assertEqual("Line", first_line("Line")),
|
||||||
|
?assertEqual("Line", first_line("Line\nLine")).
|
||||||
|
|
||||||
-endif.
|
-endif.
|
||||||
|
|
Loading…
Reference in New Issue
Block a user