diff options
author | Jaime Martinez <jmartinez@gitlab.com> | 2022-02-03 01:05:39 +0300 |
---|---|---|
committer | Jaime Martinez <jmartinez@gitlab.com> | 2022-02-03 01:05:39 +0300 |
commit | f2fd9a8e0b4778991adf054ef8f3a7244200a60d (patch) | |
tree | ccc406743b9aef9ca442def3cb7dbb4d395a2032 /internal | |
parent | 9e0d895cb3cc337385d3d3d5b67fc3487eb1f7f7 (diff) | |
parent | 6f23e35ffe9665ab17af54824a7de2b014829069 (diff) |
Merge branch 'sh-normalize-status-code-logging' into 'master'
fix: ensure logging status codes field names are consistent
See merge request gitlab-org/gitlab-pages!679
Diffstat (limited to 'internal')
-rw-r--r-- | internal/auth/auth.go | 6 | ||||
-rw-r--r-- | internal/httprange/http_reader.go | 5 |
2 files changed, 9 insertions, 2 deletions
diff --git a/internal/auth/auth.go b/internal/auth/auth.go index 2f0395df..98bbf49d 100644 --- a/internal/auth/auth.go +++ b/internal/auth/auth.go @@ -18,6 +18,7 @@ import ( "github.com/gorilla/sessions" "github.com/sirupsen/logrus" "gitlab.com/gitlab-org/labkit/errortracking" + "gitlab.com/gitlab-org/labkit/log" "golang.org/x/crypto/hkdf" "gitlab.com/gitlab-org/gitlab-pages/internal/httperrors" @@ -538,7 +539,10 @@ func (a *Auth) checkAuthentication(w http.ResponseWriter, r *http.Request, domai if resp.StatusCode != http.StatusOK { // call serve404 handler when auth fails err := fmt.Errorf("unexpected response fetching access token status: %d", resp.StatusCode) - logRequest(r).WithError(err).WithField("status", resp.Status).Error("Unexpected response fetching access token") + logRequest(r).WithError(err).WithFields(log.Fields{ + "status": resp.StatusCode, + "status_text": resp.Status, + }).Error("Unexpected response fetching access token") captureErrWithReqAndStackTrace(err, r) domain.ServeNotFoundAuthFailed(w, r) return true diff --git a/internal/httprange/http_reader.go b/internal/httprange/http_reader.go index b9affc6d..08779bc8 100644 --- a/internal/httprange/http_reader.go +++ b/internal/httprange/http_reader.go @@ -87,7 +87,10 @@ func (r *Reader) ensureResponse() error { // cleanup body on failure from r.setResponse to avoid memory leak res.Body.Close() - logging.LogRequest(req).WithError(err).WithField("status", res.Status).Error(rangeRequestFailedErrMsg) + logging.LogRequest(req).WithError(err).WithFields(log.Fields{ + "status": res.StatusCode, + "status_text": res.Status, + }).Error(rangeRequestFailedErrMsg) } return err |