Improve logging when sending events (#883)

We have some failing sytests on sqlite but it's very difficult to debug
due to lack of useful logging. This adds a log line for when a new event
is sent (incl. logging the event ID) as well as adding a user_id field
for all contextual logs so we know who initiated certain actions.
This commit is contained in:
Kegsay 2020-03-09 14:37:51 +00:00 committed by GitHub
parent c31cb02271
commit cdc1157785
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 5 additions and 0 deletions

View file

@ -25,6 +25,10 @@ func MakeAuthAPI(
if err != nil {
return *err
}
// add the user ID to the logger
logger := util.GetLogger((req.Context()))
logger = logger.WithField("user_id", device.UserID)
req = req.WithContext(util.ContextWithLogger(req.Context(), logger))
return f(req, device)
}