From f14e5ffa3af0aacf1357c7899fcde4b94418c51c Mon Sep 17 00:00:00 2001 From: Diego Bernardes Date: Wed, 8 May 2024 10:14:07 +0100 Subject: [PATCH] Reduce log output Set the log level to info and the HTTP middleware logger to debug. --- cmd/main.go | 2 +- internal/transport/middleware.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/main.go b/cmd/main.go index ef9cdf1..5a0804e 100644 --- a/cmd/main.go +++ b/cmd/main.go @@ -17,7 +17,7 @@ import ( func main() { var ( - logger = zerolog.New(os.Stdout).With().Timestamp().Caller().Logger() + logger = zerolog.New(os.Stdout).With().Timestamp().Caller().Logger().Level(zerolog.InfoLevel) urlSigningSecret = os.Getenv("URL_SIGNING_SECRET") enableDatadog = os.Getenv("ENABLE_DATADOG") rawStorageBucketRegion = os.Getenv("STORAGE_BUCKET_REGION") diff --git a/internal/transport/middleware.go b/internal/transport/middleware.go index 3cdfdff..99d18fa 100644 --- a/internal/transport/middleware.go +++ b/internal/transport/middleware.go @@ -83,7 +83,7 @@ func (m middleware) logger(next http.Handler) http.Handler { t1 := time.Now() reqID := chiMiddleware.GetReqID(r.Context()) - entry := log.Info(). + entry := log.Debug(). Str("requestID", reqID). Str("method", r.Method). Str("endpoint", requestURI). @@ -111,7 +111,7 @@ func (m middleware) logger(next http.Handler) http.Handler { next.ServeHTTP(ww, r) status := ww.Status() - entry = log.Info(). + entry = log.Debug(). Err(r.Context().Err()). Str("requestID", reqID). Dur("duration", time.Since(t1)).