Преглед изворни кода

Prettyprint webmachine and cowboy error_logger messages

pull/110/head
Andrew Thompson пре 12 година
родитељ
комит
9e5371a696
1 измењених фајлова са 28 додато и 0 уклоњено
  1. +28
    -0
      src/error_logger_lager_h.erl

+ 28
- 0
src/error_logger_lager_h.erl Прегледај датотеку

@ -86,6 +86,34 @@ handle_event(Event, State) ->
?CRASH_LOG(Event),
?LOGFMT(error, Pid, "gen_event ~w installed in ~w terminated with reason: ~s",
[ID, Name, format_reason(Reason)]);
"** Cowboy handler"++_ ->
%% Cowboy HTTP server error
?CRASH_LOG(Event),
case Args of
[Module, Function, Arity, _Request, _State] ->
%% we only get the 5-element list when its a non-exported function
?LOGFMT(error, Pid,
"Cowboy handler ~p terminated with reason: call to undefined function ~p:~p/~p",
[Module, Module, Function, Arity]);
[Module, Function, Arity | Tail] ->
%% any other cowboy error_format list *always* ends with the stacktrace
StackTrace = lists:last(Tail),
?LOGFMT(error, Pid,
"Cowboy handler ~p terminated in ~p:~p/~p with reason: ~s",
[Module, Module, Function, Arity, format_reason(StackTrace)])
end;
"webmachine error"++_ ->
%% Webmachine HTTP server error
?CRASH_LOG(Event),
[Path, Error] = Args,
%% webmachine likes to mangle the stack, for some reason
StackTrace = case Error of
{error, {error, Reason, Stack}} ->
{Reason, Stack};
_ ->
Error
end,
?LOGFMT(error, Pid, "Webmachine error at path ~p : ~s", [Path, format_reason(StackTrace)]);
_ ->
?CRASH_LOG(Event),
?LOGMSG(error, Pid, lager:safe_format(Fmt, Args, ?DEFAULT_TRUNCATION))

Loading…
Откажи
Сачувај