Permalink
Browse files

Merge branch 'log-proplist-req'

  • Loading branch information...
2 parents 4fb2a6f + 5a7040e commit ba75e8b8ae5629ea24815f28da944a489bfa0a3e Loïc Hoguin committed Apr 1, 2012
Showing with 16 additions and 8 deletions.
  1. +8 −4 src/cowboy_http_protocol.erl
  2. +2 −1 src/cowboy_http_rest.erl
  3. +6 −3 src/cowboy_http_websocket.erl
@@ -261,12 +261,13 @@ handler_init(Req, State=#state{transport=Transport,
upgrade_protocol(Req, State, Module)
catch Class:Reason ->
error_terminate(500, State),
+ PLReq = lists:zip(record_info(fields, http_req), tl(tuple_to_list(Req))),
error_logger:error_msg(
"** Handler ~p terminating in init/3~n"
" for the reason ~p:~p~n"
"** Options were ~p~n"
"** Request was ~p~n** Stacktrace: ~p~n~n",
- [Handler, Class, Reason, Opts, Req, erlang:get_stacktrace()])
+ [Handler, Class, Reason, Opts, PLReq, erlang:get_stacktrace()])
end.
-spec upgrade_protocol(#http_req{}, #state{}, atom()) -> ok.
@@ -283,13 +284,14 @@ handler_handle(HandlerState, Req, State=#state{handler={Handler, Opts}}) ->
{ok, Req2, HandlerState2} ->
terminate_request(HandlerState2, Req2, State)
catch Class:Reason ->
+ PLReq = lists:zip(record_info(fields, http_req), tl(tuple_to_list(Req))),
error_logger:error_msg(
"** Handler ~p terminating in handle/2~n"
" for the reason ~p:~p~n"
"** Options were ~p~n** Handler state was ~p~n"
"** Request was ~p~n** Stacktrace: ~p~n~n",
[Handler, Class, Reason, Opts,
- HandlerState, Req, erlang:get_stacktrace()]),
+ HandlerState, PLReq, erlang:get_stacktrace()]),
handler_terminate(HandlerState, Req, State),
error_terminate(500, State)
end.
@@ -341,13 +343,14 @@ handler_call(HandlerState, Req, State=#state{handler={Handler, Opts}},
handler_before_loop(HandlerState2, Req2,
State#state{hibernate=true})
catch Class:Reason ->
+ PLReq = lists:zip(record_info(fields, http_req), tl(tuple_to_list(Req))),
error_logger:error_msg(
"** Handler ~p terminating in info/3~n"
" for the reason ~p:~p~n"
"** Options were ~p~n** Handler state was ~p~n"
"** Request was ~p~n** Stacktrace: ~p~n~n",
[Handler, Class, Reason, Opts,
- HandlerState, Req, erlang:get_stacktrace()]),
+ HandlerState, PLReq, erlang:get_stacktrace()]),
handler_terminate(HandlerState, Req, State),
error_terminate(500, State)
end.
@@ -357,13 +360,14 @@ handler_terminate(HandlerState, Req, #state{handler={Handler, Opts}}) ->
try
Handler:terminate(Req#http_req{resp_state=locked}, HandlerState)
catch Class:Reason ->
+ PLReq = lists:zip(record_info(fields, http_req), tl(tuple_to_list(Req))),
error_logger:error_msg(
"** Handler ~p terminating in terminate/2~n"
" for the reason ~p:~p~n"
"** Options were ~p~n** Handler state was ~p~n"
"** Request was ~p~n** Stacktrace: ~p~n~n",
[Handler, Class, Reason, Opts,
- HandlerState, Req, erlang:get_stacktrace()])
+ HandlerState, PLReq, erlang:get_stacktrace()])
end.
-spec terminate_request(any(), #http_req{}, #state{}) -> ok.
View
@@ -68,11 +68,12 @@ upgrade(_ListenerPid, Handler, Opts, Req) ->
service_available(Req, #state{handler=Handler})
end
catch Class:Reason ->
+ PLReq = lists:zip(record_info(fields, http_req), tl(tuple_to_list(Req))),
error_logger:error_msg(
"** Handler ~p terminating in rest_init/3~n"
" for the reason ~p:~p~n** Options were ~p~n"
"** Request was ~p~n** Stacktrace: ~p~n~n",
- [Handler, Class, Reason, Opts, Req, erlang:get_stacktrace()]),
+ [Handler, Class, Reason, Opts, PLReq, erlang:get_stacktrace()]),
{ok, _Req2} = cowboy_http_req:reply(500, Req),
close
end.
@@ -130,11 +130,12 @@ handler_init(State=#state{handler=Handler, opts=Opts},
upgrade_denied(Req2)
catch Class:Reason ->
upgrade_error(Req),
+ PLReq = lists:zip(record_info(fields, http_req), tl(tuple_to_list(Req))),
error_logger:error_msg(
"** Handler ~p terminating in websocket_init/3~n"
" for the reason ~p:~p~n** Options were ~p~n"
"** Request was ~p~n** Stacktrace: ~p~n~n",
- [Handler, Class, Reason, Opts, Req, erlang:get_stacktrace()])
+ [Handler, Class, Reason, Opts, PLReq, erlang:get_stacktrace()])
end.
-spec upgrade_error(#http_req{}) -> closed.
@@ -395,13 +396,14 @@ handler_call(State=#state{handler=Handler, opts=Opts}, Req, HandlerState,
{shutdown, Req2, HandlerState2} ->
websocket_close(State, Req2, HandlerState2, {normal, shutdown})
catch Class:Reason ->
+ PLReq = lists:zip(record_info(fields, http_req), tl(tuple_to_list(Req))),
error_logger:error_msg(
"** Handler ~p terminating in ~p/3~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,
- HandlerState, Req, erlang:get_stacktrace()]),
+ HandlerState, PLReq, erlang:get_stacktrace()]),
websocket_close(State, Req, HandlerState, {error, handler})
end.
@@ -443,13 +445,14 @@ handler_terminate(#state{handler=Handler, opts=Opts},
try
Handler:websocket_terminate(TerminateReason, Req, HandlerState)
catch Class:Reason ->
+ PLReq = lists:zip(record_info(fields, http_req), tl(tuple_to_list(Req))),
error_logger:error_msg(
"** Handler ~p terminating in websocket_terminate/3~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,
- HandlerState, Req, erlang:get_stacktrace()])
+ HandlerState, PLReq, erlang:get_stacktrace()])
end,
closed.

0 comments on commit ba75e8b

Please sign in to comment.