couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From iil...@apache.org
Subject [27/50] couch-httpd commit: updated refs/heads/split_out_httpd_stack to e44a372
Date Tue, 01 Mar 2016 20:01:00 GMT
Extract maybe_log_response function


Project: http://git-wip-us.apache.org/repos/asf/couchdb-couch-httpd/repo
Commit: http://git-wip-us.apache.org/repos/asf/couchdb-couch-httpd/commit/460d75de
Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-httpd/tree/460d75de
Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-httpd/diff/460d75de

Branch: refs/heads/split_out_httpd_stack
Commit: 460d75de7adeb954988cb42a966ba8c44e1f4a8c
Parents: 2bde01e
Author: ILYA Khlopotov <iilyak@ca.ibm.com>
Authored: Fri Feb 26 10:38:07 2016 -0800
Committer: ILYA Khlopotov <iilyak@ca.ibm.com>
Committed: Tue Mar 1 08:35:08 2016 -0800

----------------------------------------------------------------------
 src/couch_httpd.erl | 14 ++++++++------
 1 file changed, 8 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch-httpd/blob/460d75de/src/couch_httpd.erl
----------------------------------------------------------------------
diff --git a/src/couch_httpd.erl b/src/couch_httpd.erl
index 1ac15a4..80f79af 100644
--- a/src/couch_httpd.erl
+++ b/src/couch_httpd.erl
@@ -201,12 +201,7 @@ start_delayed_json_response(Req, Code, Headers, FirstChunk) ->
 
 send_response(#httpd{}=Req, Code, Headers, Body) ->
     Resp = handle_response(Req, Code, Headers, Body, respond),
-    if Code >= 500 ->
-        couch_log:error("httpd ~p error response:~n ~s", [Code, Body]);
-    Code >= 400 ->
-        couch_log:debug("httpd ~p error response:~n ~s", [Code, Body]);
-    true -> ok
-    end,
+    maybe_log_response(Code, Body),
     {ok, Resp}.
 
 send_json(Req, Value) ->
@@ -949,6 +944,13 @@ respond_(#httpd{mochi_req = MochiReq}, Code, Headers, _Args, start_response)
->
 respond_(#httpd{mochi_req = MochiReq}, Code, Headers, Args, Type) ->
     MochiReq:Type({Code, Headers, Args}).
 
+maybe_log_response(Code, Body) when Code >= 500 ->
+    couch_log:error("httpd ~p error response:~n ~s", [Code, Body]);
+maybe_log_response(Code, Body) when Code >= 400 ->
+    couch_log:debug("httpd ~p error response:~n ~s", [Code, Body]);
+maybe_log_response(_, _) ->
+    ok.
+
 %%%%%%%% module tests below %%%%%%%%
 
 -ifdef(TEST).


Mime
View raw message