mirror of
https://github.com/ninenines/cowboy.git
synced 2025-07-15 12:40:25 +00:00
Make the arguments to error_logger more consistent
The purpose of this patch is to make the arguments cowboy passes to error_logger more consistent. With this patch there's only 3 variations on the error_logger argument list; a 5 element list, an 8 element list and a 10 element list. In all cases, the first 3 arguments are the Module, Function and Arity of the function being called and the second-to-last argument is always the Request. Additionally, for lists longer than 5 elements, the last argument is always the stack-trace. The added consistency of the argument ordering makes it much easier to write code in lager's error_logger handler to catch these messages and write a pretty one-liner (while writing the full message to the crash.log).
This commit is contained in:
parent
ea7af4b724
commit
d916d739d4
3 changed files with 21 additions and 21 deletions
|
@ -130,12 +130,12 @@ handler_init(State=#state{transport=Transport, handler=Handler, opts=Opts},
|
|||
closed
|
||||
catch Class:Reason ->
|
||||
upgrade_error(Req),
|
||||
PLReq = cowboy_req:to_list(Req),
|
||||
error_logger:error_msg(
|
||||
"** Cowboy handler ~p terminating in websocket_init/3~n"
|
||||
"** Cowboy handler ~p terminating in ~p/~p~n"
|
||||
" for the reason ~p:~p~n** Options were ~p~n"
|
||||
"** Request was ~p~n** Stacktrace: ~p~n~n",
|
||||
[Handler, Class, Reason, Opts, PLReq, erlang:get_stacktrace()])
|
||||
[Handler, websocket_init, 3, Class, Reason, Opts,
|
||||
cowboy_req:to_list(Req),erlang:get_stacktrace()])
|
||||
end.
|
||||
|
||||
-spec upgrade_error(cowboy_req:req()) -> closed.
|
||||
|
@ -507,11 +507,11 @@ handler_call(State=#state{handler=Handler, opts=Opts}, Req, HandlerState,
|
|||
catch Class:Reason ->
|
||||
PLReq = cowboy_req:to_list(Req),
|
||||
error_logger:error_msg(
|
||||
"** Cowboy handler ~p terminating in ~p/3~n"
|
||||
"** Cowboy handler ~p terminating in ~p/~p~n"
|
||||
" for the reason ~p:~p~n** Message was ~p~n"
|
||||
"** Options were ~p~n** Handler state was ~p~n"
|
||||
"** Request was ~p~n** Stacktrace: ~p~n~n",
|
||||
[Handler, Callback, Class, Reason, Message, Opts,
|
||||
[Handler, Callback, 3, Class, Reason, Message, Opts,
|
||||
HandlerState, PLReq, erlang:get_stacktrace()]),
|
||||
websocket_close(State, Req, HandlerState, {error, handler})
|
||||
end.
|
||||
|
@ -598,11 +598,11 @@ handler_terminate(#state{handler=Handler, opts=Opts},
|
|||
catch Class:Reason ->
|
||||
PLReq = cowboy_req:to_list(Req),
|
||||
error_logger:error_msg(
|
||||
"** Cowboy handler ~p terminating in websocket_terminate/3~n"
|
||||
"** Cowboy handler ~p terminating in ~p/~p~n"
|
||||
" for the reason ~p:~p~n** Initial reason was ~p~n"
|
||||
"** Options were ~p~n** Handler state was ~p~n"
|
||||
"** Request was ~p~n** Stacktrace: ~p~n~n",
|
||||
[Handler, Class, Reason, TerminateReason, Opts,
|
||||
[Handler, websocket_terminate, 3, Class, Reason, TerminateReason, Opts,
|
||||
HandlerState, PLReq, erlang:get_stacktrace()])
|
||||
end,
|
||||
closed.
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue