From d916d739d4f844da69ec1c3472b74008dc828e58 Mon Sep 17 00:00:00 2001 From: Andrew Thompson Date: Thu, 13 Dec 2012 03:38:38 -0500 Subject: 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). --- src/cowboy_rest.erl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'src/cowboy_rest.erl') diff --git a/src/cowboy_rest.erl b/src/cowboy_rest.erl index 35ca34d..c6b53bd 100644 --- a/src/cowboy_rest.erl +++ b/src/cowboy_rest.erl @@ -73,10 +73,10 @@ upgrade(_ListenerPid, Handler, Opts, Req) -> catch Class:Reason -> PLReq = cowboy_req:to_list(Req), error_logger:error_msg( - "** Cowboy handler ~p terminating in rest_init/2~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, rest_init, 2, Class, Reason, Opts, PLReq, erlang:get_stacktrace()]), {ok, _Req2} = cowboy_req:reply(500, Req), close end. @@ -735,9 +735,9 @@ choose_content_type(Req, no_call -> error_logger:error_msg( "** Cowboy handler ~p terminating; " - "function ~p was not exported~n" + "function ~p/~p was not exported~n" "** Request was ~p~n** State was ~p~n~n", - [Handler, Fun, cowboy_req:to_list(Req), HandlerState]), + [Handler, Fun, 2, cowboy_req:to_list(Req), HandlerState]), {ok, _} = cowboy_req:reply(500, Req), close; {halt, Req2, HandlerState} -> @@ -787,9 +787,9 @@ set_resp_body(Req, State=#state{handler=Handler, handler_state=HandlerState, no_call -> error_logger:error_msg( "** Cowboy handler ~p terminating; " - "function ~p was not exported~n" + "function ~p/~p was not exported~n" "** Request was ~p~n** State was ~p~n~n", - [Handler, Fun, cowboy_req:to_list(Req5), HandlerState]), + [Handler, Fun, 2, cowboy_req:to_list(Req5), HandlerState]), {ok, _} = cowboy_req:reply(500, Req5), close; {halt, Req6, HandlerState} -> -- cgit v1.2.3