Bring log_request/2 from original
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/d81ba2dd Tree: http://git-wip-us.apache.org/repos/asf/couchdb-couch-httpd/tree/d81ba2dd Diff: http://git-wip-us.apache.org/repos/asf/couchdb-couch-httpd/diff/d81ba2dd Branch: refs/heads/split_out_httpd_stack Commit: d81ba2dd433a29a8954785f4f185ba3da87c93d9 Parents: 17375fd Author: ILYA Khlopotov <iil...@ca.ibm.com> Authored: Thu Feb 25 11:06:48 2016 -0800 Committer: ILYA Khlopotov <iil...@ca.ibm.com> Committed: Tue Mar 1 08:35:07 2016 -0800 ---------------------------------------------------------------------- src/couch_httpd.erl | 15 +++++++++++++++ src/couch_httpd_original.erl | 19 +++---------------- 2 files changed, 18 insertions(+), 16 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/couchdb-couch-httpd/blob/d81ba2dd/src/couch_httpd.erl ---------------------------------------------------------------------- diff --git a/src/couch_httpd.erl b/src/couch_httpd.erl index 83c39cc..bf44e96 100644 --- a/src/couch_httpd.erl +++ b/src/couch_httpd.erl @@ -48,6 +48,7 @@ ]). -export([ + log_request/2, server_header/0, send_chunk/2, last_chunk/1 @@ -487,6 +488,20 @@ chunked_response_buffer_size() -> %% ================ %% Helper functions +log_request(#httpd{mochi_req=MochiReq,peer=Peer}=Req, Code) -> + case erlang:get(dont_log_request) of + true -> + ok; + _ -> + couch_log:notice("~s - - ~s ~s ~B", [ + Peer, + MochiReq:get(method), + MochiReq:get(raw_path), + Code + ]), + gen_event:notify(couch_plugin, {log_request, Req, Code}) + end. + server_header() -> [{"Server", "CouchDB/" ++ couch_server:get_version() ++ " (Erlang OTP/" ++ erlang:system_info(otp_release) ++ ")"}]. http://git-wip-us.apache.org/repos/asf/couchdb-couch-httpd/blob/d81ba2dd/src/couch_httpd_original.erl ---------------------------------------------------------------------- diff --git a/src/couch_httpd_original.erl b/src/couch_httpd_original.erl index 3ac0a7e..b003fea 100644 --- a/src/couch_httpd_original.erl +++ b/src/couch_httpd_original.erl @@ -21,7 +21,7 @@ -export([etag_match/2, etag_respond/3, etag_maybe/2]). --export([start_chunked_response/3,send_chunk/2,log_request/2]). +-export([start_chunked_response/3,send_chunk/2]). -export([start_response_length/4, start_response/3]). -export([send_response/4,send_error/2,send_error/4, send_chunked_error/2]). -export([parse_multipart_request/3]). @@ -65,7 +65,8 @@ send_method_not_allowed/2, send_redirect/2, absolute_uri/2, - body/1 + body/1, + log_request/2 ]). -define(HANDLER_NAME_IN_MODULE_POS, 6). @@ -509,20 +510,6 @@ verify_is_server_admin(#user_ctx{roles=Roles}) -> false -> throw({unauthorized, <<"You are not a server admin.">>}) end. -log_request(#httpd{mochi_req=MochiReq,peer=Peer}=Req, Code) -> - case erlang:get(dont_log_request) of - true -> - ok; - _ -> - couch_log:notice("~s - - ~s ~s ~B", [ - Peer, - MochiReq:get(method), - MochiReq:get(raw_path), - Code - ]), - gen_event:notify(couch_plugin, {log_request, Req, Code}) - 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]),