Logging improvements, etc.
This commit is contained in:
@@ -115,9 +115,9 @@ func (t *topic) CancelSubscribers(exceptUserID string) {
|
||||
if s.userID != exceptUserID {
|
||||
log.
|
||||
Tag(tagSubscribe).
|
||||
With(t).
|
||||
Fields(log.Context{
|
||||
"message_topic": t.ID,
|
||||
"user_id": s.userID,
|
||||
"user_id": s.userID,
|
||||
}).
|
||||
Debug("Canceling subscriber %s", s.userID)
|
||||
s.cancel()
|
||||
@@ -125,6 +125,20 @@ func (t *topic) CancelSubscribers(exceptUserID string) {
|
||||
}
|
||||
}
|
||||
|
||||
func (t *topic) Context() log.Context {
|
||||
t.mu.RLock()
|
||||
defer t.mu.RUnlock()
|
||||
fields := map[string]any{
|
||||
"topic": t.ID,
|
||||
"topic_subscribers": len(t.subscribers),
|
||||
}
|
||||
if t.rateVisitor != nil {
|
||||
fields["topic_rate_visitor_ip"] = t.rateVisitor.IP().String()
|
||||
fields["topic_rate_visitor_user_id"] = t.rateVisitor.MaybeUserID()
|
||||
}
|
||||
return fields
|
||||
}
|
||||
|
||||
// subscribersCopy returns a shallow copy of the subscribers map
|
||||
func (t *topic) subscribersCopy() map[int]*topicSubscriber {
|
||||
t.mu.Lock()
|
||||
|
||||
Reference in New Issue
Block a user