couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From iil...@apache.org
Subject [4/5] couch commit: updated refs/heads/master to 40adf24
Date Thu, 03 Mar 2016 20:05:01 GMT
Suppress log of a response for clustered interface

COUCHDB-2945


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

Branch: refs/heads/master
Commit: 7cf698e2dfb9986f54ad3d02476727d94299b7fc
Parents: f58817f
Author: ILYA Khlopotov <iilyak@ca.ibm.com>
Authored: Thu Mar 3 08:08:46 2016 -0800
Committer: ILYA Khlopotov <iilyak@ca.ibm.com>
Committed: Thu Mar 3 11:38:17 2016 -0800

----------------------------------------------------------------------
 src/couch_httpd.erl | 20 +++++++++++++-------
 1 file changed, 13 insertions(+), 7 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-couch/blob/7cf698e2/src/couch_httpd.erl
----------------------------------------------------------------------
diff --git a/src/couch_httpd.erl b/src/couch_httpd.erl
index c88e2e7..645176b 100644
--- a/src/couch_httpd.erl
+++ b/src/couch_httpd.erl
@@ -649,6 +649,18 @@ log_request(#httpd{mochi_req=MochiReq,peer=Peer}=Req, Code) ->
             gen_event:notify(couch_plugin, {log_request, Req, Code})
     end.
 
+log_response(Code, Body) ->
+    case erlang:get(dont_log_response) of
+        true ->
+            ok;
+        _ when Code >= 500 ->
+            couch_log:error("httpd ~p error response:~n ~s", [Code, Body]);
+        _ when Code >= 400 ->
+            couch_log:error("httpd ~p error response:~n ~s", [Code, Body]);
+        _ ->
+            ok
+    end.
+
 start_response_length(#httpd{mochi_req=MochiReq}=Req, Code, Headers, Length) ->
     log_request(Req, Code),
     couch_stats:increment_counter([couchdb, httpd_status_codes, Code]),
@@ -729,15 +741,9 @@ send_response_no_cors(#httpd{mochi_req=MochiReq}=Req, Code, Headers,
Body) ->
     log_request(Req, Code),
     couch_stats:increment_counter([couchdb, httpd_status_codes, Code]),
     Headers1 = http_1_0_keep_alive(MochiReq, Headers),
-    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,
     Headers2 = Headers1 ++ server_header() ++
                couch_httpd_auth:cookie_auth_header(Req, Headers1),
-
+    log_response(Code, Body),
     {ok, MochiReq:respond({Code, Headers2, Body})}.
 
 send_method_not_allowed(Req, Methods) ->


Mime
View raw message