Skip to content

Commit f08a504

Browse files
committed
feat(integrations): more informative logs
1 parent 66611eb commit f08a504

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

api/integration.go

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,9 @@ func ReceiveIntegration(w http.ResponseWriter, r *http.Request) {
109109
"sha256=")
110110

111111
if !ok {
112-
log.Error("Invalid HMAC signature")
112+
log.WithFields(log.Fields{
113+
"context": "integrations",
114+
}).Error("Invalid GitHub/HMAC signature")
113115
continue
114116
}
115117
case db.IntegrationAuthBitbucket:
@@ -120,7 +122,9 @@ func ReceiveIntegration(w http.ResponseWriter, r *http.Request) {
120122
"sha256=")
121123

122124
if !ok {
123-
log.Error("Invalid HMAC signature")
125+
log.WithFields(log.Fields{
126+
"context": "integrations",
127+
}).Error("Invalid Bitbucket/HMAC signature")
124128
continue
125129
}
126130
case db.IntegrationAuthHmac:
@@ -131,32 +135,42 @@ func ReceiveIntegration(w http.ResponseWriter, r *http.Request) {
131135
"")
132136

133137
if !ok {
134-
log.Error("Invalid HMAC signature")
138+
log.WithFields(log.Fields{
139+
"context": "integrations",
140+
}).Error("Invalid HMAC signature")
135141
continue
136142
}
137143
case db.IntegrationAuthToken:
138144
if integration.AuthSecret.LoginPassword.Password != r.Header.Get(integration.AuthHeader) {
139-
log.Error("Invalid verification token")
145+
log.WithFields(log.Fields{
146+
"context": "integrations",
147+
}).Error("Invalid verification token")
140148
continue
141149
}
142150
case db.IntegrationAuthBasic:
143151
var username, password, auth = r.BasicAuth()
144152
if !auth || integration.AuthSecret.LoginPassword.Password != password || integration.AuthSecret.LoginPassword.Login != username {
145-
log.Error("Invalid BasicAuth: incorrect login or password")
153+
log.WithFields(log.Fields{
154+
"context": "integrations",
155+
}).Error("Invalid BasicAuth: incorrect login or password")
146156
continue
147157
}
148158
case db.IntegrationAuthNone:
149159
// Do nothing
150160
default:
151-
log.Error("Unknown verification method: " + integration.AuthMethod)
161+
log.WithFields(log.Fields{
162+
"context": "integrations",
163+
}).Error("Unknown verification method: " + integration.AuthMethod)
152164
continue
153165
}
154166

155167
if level != db.IntegrationAliasSingle {
156168
var matchers []db.IntegrationMatcher
157169
matchers, err = store.GetIntegrationMatchers(integration.ProjectID, db.RetrieveQueryParams{}, integration.ID)
158170
if err != nil {
159-
log.Error(err)
171+
log.WithFields(log.Fields{
172+
"context": "integrations",
173+
}).WithError(err).Error("Could not retrieve matchers")
160174
continue
161175
}
162176

0 commit comments

Comments
 (0)