mirror of
https://github.com/binwiederhier/ntfy.git
synced 2025-06-13 16:13:18 +02:00
Logging improvements, etc.
This commit is contained in:
parent
f7f343fe55
commit
8215b66db3
12 changed files with 155 additions and 80 deletions
server
|
@ -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()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue