浏览代码

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

pull/8/head
Scott Lystig Fritchie 13 年前
父节点
当前提交
83c2a412ab
共有 3 个文件被更改,包括 10 次插入4 次删除
  1. +3
    -3
      src/error_logger_lager_h.erl
  2. +1
    -1
      src/lager_crash_log.erl
  3. +6
    -0
      test/lager_test_backend.erl

+ 3
- 3
src/error_logger_lager_h.erl 查看文件

@ -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

+ 1
- 1
src/lager_crash_log.erl 查看文件

@ -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),

+ 6
- 0
test/lager_test_backend.erl 查看文件

@ -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.

正在加载...
取消
保存