fix: Install Terraform once and only log >=500 (#4339)

Fixes #4302.
This commit is contained in:
Kyle Carberry
2022-10-03 15:19:02 -05:00
committed by GitHub
parent aa3812ff4e
commit 9bc0d06aa0
2 changed files with 22 additions and 14 deletions

View File

@ -25,7 +25,7 @@ func Logger(log slog.Logger) func(next http.Handler) http.Handler {
next.ServeHTTP(sw, r)
// Don't log successful health check requests.
if r.URL.Path == "/api/v2" && sw.Status == 200 {
if r.URL.Path == "/api/v2" && sw.Status == http.StatusOK {
return
}
@ -37,7 +37,7 @@ func Logger(log slog.Logger) func(next http.Handler) http.Handler {
// For status codes 400 and higher we
// want to log the response body.
if sw.Status >= 400 {
if sw.Status >= http.StatusInternalServerError {
httplog = httplog.With(
slog.F("response_body", string(sw.ResponseBody())),
)
@ -47,7 +47,7 @@ func Logger(log slog.Logger) func(next http.Handler) http.Handler {
// includes proxy errors etc. It also causes slogtest to fail
// instantly without an error message by default.
logLevelFn := httplog.Debug
if sw.Status >= 400 {
if sw.Status >= http.StatusInternalServerError {
logLevelFn = httplog.Warn
}