couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dam...@apache.org
Subject svn commit: r815927 - in /couchdb/trunk/src/couchdb: couch_db.hrl couch_httpd.erl
Date Wed, 16 Sep 2009 19:05:09 GMT
Author: damien
Date: Wed Sep 16 19:05:08 2009
New Revision: 815927

URL: http://svn.apache.org/viewvc?rev=815927&view=rev
Log:
Single line http request when log=info

Modified:
    couchdb/trunk/src/couchdb/couch_db.hrl
    couchdb/trunk/src/couchdb/couch_httpd.erl

Modified: couchdb/trunk/src/couchdb/couch_db.hrl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_db.hrl?rev=815927&r1=815926&r2=815927&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_db.hrl (original)
+++ couchdb/trunk/src/couchdb/couch_db.hrl Wed Sep 16 19:05:08 2009
@@ -65,6 +65,7 @@
 
 -record(httpd,
     {mochi_req,
+    peer,
     method,
     path_parts,
     db_url_handlers,

Modified: couchdb/trunk/src/couchdb/couch_httpd.erl
URL: http://svn.apache.org/viewvc/couchdb/trunk/src/couchdb/couch_httpd.erl?rev=815927&r1=815926&r2=815927&view=diff
==============================================================================
--- couchdb/trunk/src/couchdb/couch_httpd.erl (original)
+++ couchdb/trunk/src/couchdb/couch_httpd.erl Wed Sep 16 19:05:08 2009
@@ -135,16 +135,13 @@
     {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 @@
 
     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 @@
             ?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 @@
     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 @@
     {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 @@
     {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]);



Mime
View raw message