From c9922e2539a58ec87dfab4d3e97f50d14e34991d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Pa=C3=9F?= <22845248+mpass99@users.noreply.github.com> Date: Wed, 29 Nov 2023 13:28:51 +0100 Subject: [PATCH] Decrease Log severity of failing requests because it's likely that another error with more information has already been reported. --- pkg/logging/logging.go | 6 +----- pkg/logging/logging_test.go | 16 ---------------- 2 files changed, 1 insertion(+), 21 deletions(-) diff --git a/pkg/logging/logging.go b/pkg/logging/logging.go index c7e0ab1..ed2ff06 100644 --- a/pkg/logging/logging.go +++ b/pkg/logging/logging.go @@ -93,11 +93,7 @@ func HTTPLoggingMiddleware(next http.Handler) http.Handler { "duration": latency, "user_agent": RemoveNewlineSymbol(r.UserAgent()), }) - if lrw.StatusCode >= http.StatusInternalServerError { - logEntry.Error("Failing " + path) - } else { - logEntry.Debug() - } + logEntry.Debug() }) } diff --git a/pkg/logging/logging_test.go b/pkg/logging/logging_test.go index 08b8cd8..589de27 100644 --- a/pkg/logging/logging_test.go +++ b/pkg/logging/logging_test.go @@ -25,22 +25,6 @@ func TestMainTestSuite(t *testing.T) { suite.Run(t, new(MainTestSuite)) } -func (s *MainTestSuite) TestHTTPMiddlewareWarnsWhenInternalServerError() { - var hook *test.Hook - log, hook = test.NewNullLogger() - InitializeLogging(logrus.DebugLevel.String(), dto.FormatterText) - - request, err := http.NewRequest(http.MethodGet, "/", http.NoBody) - if err != nil { - s.Fail(err.Error()) - } - recorder := httptest.NewRecorder() - HTTPLoggingMiddleware(mockHTTPStatusHandler(500)).ServeHTTP(recorder, request) - - s.Equal(1, len(hook.Entries)) - s.Equal(logrus.ErrorLevel, hook.LastEntry().Level) -} - func (s *MainTestSuite) TestHTTPMiddlewareDebugsWhenStatusOK() { var hook *test.Hook log, hook = test.NewNullLogger()