From 856170821cc9c5f0ddd6e03250f6883bc6c24f32 Mon Sep 17 00:00:00 2001 From: tammert Date: Tue, 26 May 2020 19:52:13 +0200 Subject: [PATCH] Changed default log level for web requests from INFO to DEBUG --- server/middleware.go | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/server/middleware.go b/server/middleware.go index c0ea01aa53..760d71b287 100644 --- a/server/middleware.go +++ b/server/middleware.go @@ -15,7 +15,6 @@ package server import ( "net/http" - "strings" "github.com/runatlantis/atlantis/server/logging" "github.com/urfave/negroni" @@ -31,18 +30,9 @@ type RequestLogger struct { logger *logging.SimpleLogger } -// ServeHTTP implements the middleware function. It logs a request at INFO -// level unless it's a request to /static/*. +// ServeHTTP implements the middleware function. It logs all requests at DEBUG level. func (l *RequestLogger) ServeHTTP(rw http.ResponseWriter, r *http.Request, next http.HandlerFunc) { - if l.shouldLog(r) { - l.logger.Info("%s %s – from %s", r.Method, r.URL.RequestURI(), r.RemoteAddr) - } + l.logger.Debug("%s %s – from %s", r.Method, r.URL.RequestURI(), r.RemoteAddr) next(rw, r) - if l.shouldLog(r) { - l.logger.Info("%s %s – respond HTTP %d", r.Method, r.URL.RequestURI(), rw.(negroni.ResponseWriter).Status()) - } -} - -func (l *RequestLogger) shouldLog(r *http.Request) bool { - return !strings.HasPrefix(r.URL.RequestURI(), "/static") + l.logger.Debug("%s %s – respond HTTP %d", r.Method, r.URL.RequestURI(), rw.(negroni.ResponseWriter).Status()) }