Browse Source

Use format_reason in supervisor child exit messages, too

pull/4/head
Andrew Thompson 14 years ago
parent
commit
d0338f11a8
2 changed files with 11 additions and 1 deletions
  1. +1
    -1
      src/error_logger_lager_h.erl
  2. +10
    -0
      test/lager_test_backend.erl

+ 1
- 1
src/error_logger_lager_h.erl View File

@ -90,7 +90,7 @@ handle_event(Event, State) ->
case lists:sort(D) of
[{errorContext, Ctx}, {offender, Off}, {reason, Reason}, {supervisor, Name}] ->
Offender = format_offender(Off),
?LOG(error, Pid, "Supervisor ~w had child ~s exit with reason ~w in context ~w", [element(2, Name), Offender, Reason, Ctx]);
?LOG(error, Pid, "Supervisor ~w had child ~s exit with reason ~s in context ~w", [element(2, Name), Offender, format_reason(Reason), Ctx]);
_ ->
?LOG(error, Pid, ["SUPERVISOR REPORT ", print_silly_list(D)])
end;

+ 10
- 0
test/lager_test_backend.erl View File

@ -479,6 +479,16 @@ error_logger_redirect_test_() ->
?assertEqual(Expected, lists:flatten(Msg))
end
},
{"supervisor reports with real error",
fun() ->
error_logger:error_report(supervisor_report, [{errorContext, france}, {offender, [{name, mini_steve}, {mfargs, {a, b, [c]}}, {pid, bleh}]}, {reason, {function_clause,[{crash,handle_info,[foo]}]}}, {supervisor, {local, steve}}]),
timer:sleep(100),
{_, _, Msg} = pop(),
Expected = lists:flatten(io_lib:format("[error] ~w Supervisor steve had child mini_steve started with a:b(c) at bleh exit with reason no function clause matching crash:handle_info(foo) in context france", [self()])),
?assertEqual(Expected, lists:flatten(Msg))
end
},
{"supervisor_bridge reports",
fun() ->
error_logger:error_report(supervisor_report, [{errorContext, france}, {offender, [{mod, mini_steve}, {pid, bleh}]}, {reason, fired}, {supervisor, {local, steve}}]),

Loading…
Cancel
Save