diff options
author | Kegsay <kegan@matrix.org> | 2020-03-09 14:37:51 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-03-09 14:37:51 +0000 |
commit | cdc115778551af69b4c9c39f758adcae61701aa3 (patch) | |
tree | c8e34df17c9ee61de48ad8a32d0d99b71941604d /common | |
parent | c31cb0227111ab4441d6282081ebd6494a422ba8 (diff) |
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.
Diffstat (limited to 'common')
-rw-r--r-- | common/httpapi.go | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/common/httpapi.go b/common/httpapi.go index 59b303b6..22c77447 100644 --- a/common/httpapi.go +++ b/common/httpapi.go @@ -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) } |