summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDamien F. Katz <damien@apache.org>2009-09-16 19:05:08 +0000
committerDamien F. Katz <damien@apache.org>2009-09-16 19:05:08 +0000
commit3be897ebad528a81bcec91c406ea4e390f8a2915 (patch)
tree738947118c23309c93e859110a312f18c4fca7fb /src
parent29b93930462628612da0ce6b85f5d0fb553f842f (diff)
Single line http request when log=info
git-svn-id: https://svn.apache.org/repos/asf/couchdb/trunk@815927 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'src')
-rw-r--r--src/couchdb/couch_db.hrl1
-rw-r--r--src/couchdb/couch_httpd.erl23
2 files changed, 17 insertions, 7 deletions
diff --git a/src/couchdb/couch_db.hrl b/src/couchdb/couch_db.hrl
index a52bc983..053cbaa4 100644
--- a/src/couchdb/couch_db.hrl
+++ b/src/couchdb/couch_db.hrl
@@ -65,6 +65,7 @@
-record(httpd,
{mochi_req,
+ peer,
method,
path_parts,
db_url_handlers,
diff --git a/src/couchdb/couch_httpd.erl b/src/couchdb/couch_httpd.erl
index 3518481b..6a938229 100644
--- a/src/couchdb/couch_httpd.erl
+++ b/src/couchdb/couch_httpd.erl
@@ -135,16 +135,13 @@ handle_request(MochiReq, DefaultFun,
{FirstPart, _, _} ->
list_to_binary(FirstPart)
end,
- ?LOG_INFO("~s - ~p ~s", [
- MochiReq:get(peer),
+ ?LOG_DEBUG("~p ~s ~p~nHeaders: ~p", [
MochiReq:get(method),
- RawUri
- ]),
- ?LOG_DEBUG("HTTP ~p~nHeaders: ~p", [
+ RawUri,
MochiReq:get(version),
mochiweb_headers:to_list(MochiReq:get(headers))
]),
-
+
Method1 =
case MochiReq:get(method) of
% already an atom
@@ -163,6 +160,7 @@ handle_request(MochiReq, DefaultFun,
HttpReq = #httpd{
mochi_req = MochiReq,
+ peer = MochiReq:get(peer),
method = Method,
path_parts = [list_to_binary(couch_httpd:unquote(Part))
|| Part <- string:tokens(Path, "/")],
@@ -202,7 +200,6 @@ handle_request(MochiReq, DefaultFun,
?LOG_INFO("Stacktrace: ~p",[erlang:get_stacktrace()]),
send_error(HttpReq, Error)
end,
- ?LOG_INFO("Response code: ~B", [Resp:get(code)]),
RequestTime = round(timer:now_diff(now(), Begin)/1000),
couch_stats_collector:record({couchdb, request_time}, RequestTime),
couch_stats_collector:increment({httpd, requests}),
@@ -357,7 +354,17 @@ verify_is_server_admin(#httpd{user_ctx=#user_ctx{roles=Roles}}) ->
false -> throw({unauthorized, <<"You are not a server admin.">>})
end.
+log_request(#httpd{mochi_req=MochiReq,peer=Peer,method=Method}, Code) ->
+ ?LOG_INFO("~s - - ~p ~s ~B", [
+ Peer,
+ Method,
+ MochiReq:get(raw_path),
+ Code
+ ]).
+
+
start_response_length(#httpd{mochi_req=MochiReq}=Req, Code, Headers, Length) ->
+ log_request(Req, Code),
couch_stats_collector:increment({httpd_status_codes, Code}),
Resp = MochiReq:start_response_length({Code, Headers ++ server_header() ++ couch_httpd_auth:cookie_auth_header(Req, Headers), Length}),
case MochiReq:get(method) of
@@ -371,6 +378,7 @@ send(Resp, Data) ->
{ok, Resp}.
start_chunked_response(#httpd{mochi_req=MochiReq}=Req, Code, Headers) ->
+ log_request(Req, Code),
couch_stats_collector:increment({httpd_status_codes, Code}),
Resp = MochiReq:respond({Code, Headers ++ server_header() ++ couch_httpd_auth:cookie_auth_header(Req, Headers), chunked}),
case MochiReq:get(method) of
@@ -384,6 +392,7 @@ send_chunk(Resp, Data) ->
{ok, Resp}.
send_response(#httpd{mochi_req=MochiReq}=Req, Code, Headers, Body) ->
+ log_request(Req, Code),
couch_stats_collector:increment({httpd_status_codes, Code}),
if Code >= 400 ->
?LOG_DEBUG("httpd ~p error response:~n ~s", [Code, Body]);