From bbd7ba670a77e0383477e113321d0bbc5dcb45e3 Mon Sep 17 00:00:00 2001 From: Angira Kekteeva Date: Mon, 24 Oct 2022 19:28:28 +0400 Subject: [PATCH] [#728] Add bucket and object to method logs Signed-off-by: Angira Kekteeva --- api/router.go | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/api/router.go b/api/router.go index d5b37520d..889a210a4 100644 --- a/api/router.go +++ b/api/router.go @@ -149,6 +149,7 @@ func logErrorResponse(l *zap.Logger) mux.MiddlewareFunc { return func(h http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { lw := &logResponseWriter{ResponseWriter: w} + reqInfo := GetReqInfo(r.Context()) // pass execution: h.ServeHTTP(lw, r) @@ -159,6 +160,8 @@ func logErrorResponse(l *zap.Logger) mux.MiddlewareFunc { zap.Int("status", lw.statusCode), zap.String("request_id", GetRequestID(r.Context())), zap.String("method", mux.CurrentRoute(r).GetName()), + zap.String("bucket", reqInfo.BucketName), + zap.String("object", reqInfo.ObjectName), zap.String("description", http.StatusText(lw.statusCode))) return @@ -168,6 +171,8 @@ func logErrorResponse(l *zap.Logger) mux.MiddlewareFunc { zap.Int("status", lw.statusCode), zap.String("request_id", GetRequestID(r.Context())), zap.String("method", mux.CurrentRoute(r).GetName()), + zap.String("bucket", reqInfo.BucketName), + zap.String("object", reqInfo.ObjectName), zap.String("description", http.StatusText(lw.statusCode))) }) }