Skip to content

Commit

Permalink
Log an array of targets instead of a map
Browse files Browse the repository at this point in the history
  • Loading branch information
dunglas committed Oct 6, 2019
1 parent 51f037e commit 8e2e787
Showing 1 changed file with 14 additions and 2 deletions.
16 changes: 14 additions & 2 deletions hub/log.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ func (h *Hub) createLogFields(r *http.Request, u *Update, s *Subscriber) log.Fie
"event_type": u.Type,
"event_retry": u.Retry,
"update_topics": u.Topics,
"update_targets": u.Targets,
"update_targets": targetsMapToArray(u.Targets),
}
if h.options.Debug {
fields["update_data"] = u.Data
Expand All @@ -22,8 +22,20 @@ func (h *Hub) createLogFields(r *http.Request, u *Update, s *Subscriber) log.Fie
if s != nil {
fields["last_event_id"] = s.LastEventID
fields["subscriber_topics"] = s.Topics
fields["subscriber_targets"] = s.Targets
fields["subscriber_targets"] = targetsMapToArray(s.Targets)
}

return fields
}

func targetsMapToArray(t map[string]struct{}) []string {
targets := make([]string, len(t))

var i int
for target := range t {
targets[i] = target
i++
}

return targets
}

0 comments on commit 8e2e787

Please sign in to comment.