couchdb-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From tonysu...@apache.org
Subject [1/4] chttpd commit: updated refs/heads/2992-limit-doc-size to 5181ec8 [Forced Update!]
Date Sun, 17 Apr 2016 02:44:59 GMT
Repository: couchdb-chttpd
Updated Branches:
  refs/heads/2992-limit-doc-size acb58c51d -> 5181ec865 (forced update)


Log user name of request initiator

Change the log format from chttpd to include username.
The new format is (space separated):

Nonce, Peer, Host, UserName, Method, RawUri, Code, Status, RequestTime

COUCHDB-2973


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

Branch: refs/heads/2992-limit-doc-size
Commit: d2665cec222ab447e47cdceff950269553fb6c47
Parents: 02202d3
Author: ILYA Khlopotov <iilyak@ca.ibm.com>
Authored: Mon Mar 21 12:23:31 2016 -0700
Committer: ILYA Khlopotov <iilyak@ca.ibm.com>
Committed: Fri Apr 15 09:06:37 2016 -0700

----------------------------------------------------------------------
 src/chttpd.erl | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/couchdb-chttpd/blob/d2665cec/src/chttpd.erl
----------------------------------------------------------------------
diff --git a/src/chttpd.erl b/src/chttpd.erl
index 3d2f3d9..e5c6b65 100644
--- a/src/chttpd.erl
+++ b/src/chttpd.erl
@@ -371,10 +371,11 @@ maybe_log(#httpd{} = HttpReq, #httpd_resp{should_log = true} = HttpResp)
->
         code = Code,
         status = Status
     } = HttpResp,
+    User = get_user(HttpReq),
     Host = MochiReq:get_header_value("Host"),
     RawUri = MochiReq:get(raw_path),
     RequestTime = timer:now_diff(EndTime, BeginTime) / 1000,
-    couch_log:notice("~s ~s ~s ~s ~s ~B ~p ~B", [Nonce, Peer, Host,
+    couch_log:notice("~s ~s ~s ~s ~s ~s ~B ~p ~B", [Nonce, Peer, Host, User,
         Method, RawUri, Code, Status, round(RequestTime)]);
 maybe_log(_HttpReq, #httpd_resp{should_log = false}) ->
     ok.
@@ -1085,6 +1086,10 @@ respond_(#httpd{mochi_req = MochiReq}, Code, Headers, _Args, start_response)
->
 respond_(#httpd{mochi_req = MochiReq}, Code, Headers, Args, Type) ->
     MochiReq:Type({Code, Headers, Args}).
 
+get_user(#httpd{user_ctx = #user_ctx{name = User}}) ->
+    couch_util:url_encode(User);
+get_user(#httpd{user_ctx = undefined}) ->
+    "undefined".
 
 -ifdef(TEST).
 


Mime
View raw message