Skip to content

Commit

Permalink
Prettyprint webmachine and cowboy error_logger messages
Browse files Browse the repository at this point in the history
  • Loading branch information
Vagabond committed Feb 27, 2013
1 parent 2a8706b commit 9e5371a
Showing 1 changed file with 28 additions and 0 deletions.
28 changes: 28 additions & 0 deletions src/error_logger_lager_h.erl
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down

0 comments on commit 9e5371a

Please sign in to comment.