From 7c9406cd7a33fcabdf800bbe8f1f10ccff2e9d1c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Maximilian=20Pa=C3=9F?= <22845248+mpass99@users.noreply.github.com> Date: Fri, 26 Nov 2021 21:14:27 +0100 Subject: [PATCH] Change response logging message to allow specific error tracking in sentry. See POSEIDON-F --- pkg/logging/logging.go | 4 ++-- pkg/logging/logging_test.go | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/logging/logging.go b/pkg/logging/logging.go index b8d058b..eea6ada 100644 --- a/pkg/logging/logging.go +++ b/pkg/logging/logging.go @@ -66,7 +66,7 @@ func (writer *loggingResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, erro return conn, rw, nil } -// HTTPLoggingMiddleware returns an http.Handler that logs different information about every request. +// HTTPLoggingMiddleware returns a http.Handler that logs different information about every request. func HTTPLoggingMiddleware(next http.Handler) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { start := time.Now().UTC() @@ -84,7 +84,7 @@ func HTTPLoggingMiddleware(next http.Handler) http.Handler { "user_agent": r.UserAgent(), }) if lrw.statusCode >= http.StatusInternalServerError { - logEntry.Warn() + logEntry.Error("Failing " + path) } else { logEntry.Debug() } diff --git a/pkg/logging/logging_test.go b/pkg/logging/logging_test.go index 4c0a3cf..b21277a 100644 --- a/pkg/logging/logging_test.go +++ b/pkg/logging/logging_test.go @@ -28,7 +28,7 @@ func TestHTTPMiddlewareWarnsWhenInternalServerError(t *testing.T) { HTTPLoggingMiddleware(mockHTTPStatusHandler(500)).ServeHTTP(recorder, request) assert.Equal(t, 1, len(hook.Entries)) - assert.Equal(t, logrus.WarnLevel, hook.LastEntry().Level) + assert.Equal(t, logrus.ErrorLevel, hook.LastEntry().Level) } func TestHTTPMiddlewareDebugsWhenStatusOK(t *testing.T) {