Commit 83c2a412 authored by Scott Lystig Fritchie's avatar Scott Lystig Fritchie
Browse files

Mash in the remainder of adt-error-format-protection branch

parent cf51ba06
Showing with 10 additions and 4 deletions
+10 -4
......@@ -80,7 +80,7 @@ handle_event(Event, State) ->
[ID, Name, format_reason(Reason)]);
_ ->
?CRASH_LOG(Event),
?LOG(error, Pid, lager_trunc_io:format(Fmt, Args, 4096))
?LOG(error, Pid, lager:safe_format(Fmt, Args, 4096))
end;
{error_report, _GL, {Pid, std_error, D}} ->
?CRASH_LOG(Event),
......@@ -100,11 +100,11 @@ handle_event(Event, State) ->
?CRASH_LOG(Event),
?LOG(error, Pid, ["CRASH REPORT ", format_crash_report(Self, Neighbours)]);
{warning_msg, _GL, {Pid, Fmt, Args}} ->
?LOG(warning, Pid, lager_trunc_io:format(Fmt, Args, 4096));
?LOG(warning, Pid, lager:safe_format(Fmt, Args, 4096));
{warning_report, _GL, {Pid, std_warning, Report}} ->
?LOG(warning, Pid, print_silly_list(Report));
{info_msg, _GL, {Pid, Fmt, Args}} ->
?LOG(info, Pid, lager_trunc_io:format(Fmt, Args, 4096));
?LOG(info, Pid, lager:safe_format(Fmt, Args, 4096));
{info_report, _GL, {Pid, std_info, D}} when is_list(D) ->
Details = lists:sort(D),
case Details of
......
......@@ -166,7 +166,7 @@ schedule_rotation(Date) ->
%% to limit the formatted string's size.
limited_fmt(Fmt, Args, FmtMaxBytes) ->
lager_trunc_io:format(Fmt, Args, FmtMaxBytes).
lager:safe_format(Fmt, Args, FmtMaxBytes).
limited_str(Term, FmtMaxBytes) ->
{Str, _} = lager_trunc_io:print(Term, FmtMaxBytes),
......
......@@ -647,6 +647,12 @@ error_logger_redirect_test_() ->
]
}.
safe_format_test() ->
?assertEqual("foo bar", lists:flatten(lager:safe_format("~p ~p", [foo, bar], 1024))),
?assertEqual("FORMAT ERROR: \"~p ~p ~p\" [foo,bar]", lists:flatten(lager:safe_format("~p ~p ~p", [foo, bar], 1024))),
?assertEqual("FORMAT ERROR: \"~s\" [1]", lists:flatten(lager:safe_format("~s", [1], 1024))),
ok.
-endif.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment