Skip to content

Commit

Permalink
Decrease Log severity
Browse files Browse the repository at this point in the history
of failing requests because it's likely that another error with more information has already been reported.
  • Loading branch information
mpass99 authored and MrSerth committed Nov 30, 2023
1 parent 6102759 commit c9922e2
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 21 deletions.
6 changes: 1 addition & 5 deletions pkg/logging/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
})
}

Expand Down
16 changes: 0 additions & 16 deletions pkg/logging/logging_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit c9922e2

Please sign in to comment.