Merge pull request #2941 from bakins/http-log

Simple debug HTTP request logging
This commit is contained in:
Xiang Li 2015-06-09 10:52:13 -07:00
commit ebb767765e
2 changed files with 8 additions and 1 deletions

View File

@ -104,7 +104,7 @@ func NewClientHandler(server *etcdserver.EtcdServer) http.Handler {
mux.Handle(deprecatedMachinesPrefix, dmh)
handleSecurity(mux, sech)
return mux
return requestLogger(mux)
}
type keysHandler struct {

View File

@ -78,3 +78,10 @@ func allowMethod(w http.ResponseWriter, m string, ms ...string) bool {
http.Error(w, "Method Not Allowed", http.StatusMethodNotAllowed)
return false
}
func requestLogger(handler http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
plog.Debugf("[%s] %s remote:%s", r.Method, r.RequestURI, r.RemoteAddr)
handler.ServeHTTP(w, r)
})
}