summaryrefslogtreecommitdiff
path: root/client/gitlabnet.go
diff options
context:
space:
mode:
authorIgor Drozdov <idrozdov@gitlab.com>2020-05-11 13:42:28 +0000
committerIgor Drozdov <idrozdov@gitlab.com>2020-05-11 13:42:28 +0000
commit940aa912784b2e99d6f2a767f13bd013a62c94f8 (patch)
tree96898bec50690d0d34eb9ead815b8ef4a89a40ce /client/gitlabnet.go
parent716e30c55e893ebe2385b27f85902a789f26c6ef (diff)
parentc0cf314c5722a4f7ec0a1f355d23fa2511344989 (diff)
downloadgitlab-shell-940aa912784b2e99d6f2a767f13bd013a62c94f8.tar.gz
Merge branch 'sh-add-http-status-code' into 'master'
Add HTTP status code to internal API logs Closes #450 See merge request gitlab-org/gitlab-shell!376
Diffstat (limited to 'client/gitlabnet.go')
-rw-r--r--client/gitlabnet.go10
1 files changed, 7 insertions, 3 deletions
diff --git a/client/gitlabnet.go b/client/gitlabnet.go
index 67c48c7..7fbf63e 100644
--- a/client/gitlabnet.go
+++ b/client/gitlabnet.go
@@ -123,18 +123,22 @@ func (c *GitlabNetClient) DoRequest(method, path string, data interface{}) (*htt
"url": request.URL.String(),
"duration_ms": time.Since(start) / time.Millisecond,
}
+ logger := log.WithFields(fields)
if err != nil {
- log.WithError(err).WithFields(fields).Error("Internal API unreachable")
+ logger.WithError(err).Error("Internal API unreachable")
return nil, fmt.Errorf("Internal API unreachable")
}
+ if response != nil {
+ logger = logger.WithField("status", response.StatusCode)
+ }
if err := parseError(response); err != nil {
- log.WithError(err).WithFields(fields).Error("Internal API error")
+ logger.WithError(err).Error("Internal API error")
return nil, err
}
- log.WithFields(fields).Info("Finished HTTP request")
+ logger.Info("Finished HTTP request")
return response, nil
}