Skip to content

Commit

Permalink
fix: tweak log levels on the hot path
Browse files Browse the repository at this point in the history
  • Loading branch information
dunglas committed Jan 25, 2024
1 parent d694339 commit f6ffafc
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion authorization.go
Original file line number Diff line number Diff line change
Expand Up @@ -175,7 +175,7 @@ func canDispatch(s *TopicSelectorStore, topics, topicSelectors []string) bool {

func (h *Hub) httpAuthorizationError(w http.ResponseWriter, r *http.Request, err error) {
http.Error(w, http.StatusText(http.StatusUnauthorized), http.StatusUnauthorized)
if c := h.logger.Check(zap.InfoLevel, "Topic selectors not matched, not provided or authorization error"); c != nil {
if c := h.logger.Check(zap.DebugLevel, "Topic selectors not matched, not provided or authorization error"); c != nil {
c.Write(zap.String("remote_addr", r.RemoteAddr), zap.Error(err))
}
}
2 changes: 1 addition & 1 deletion publish.go
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ func (h *Hub) PublishHandler(w http.ResponseWriter, r *http.Request) {
}

io.WriteString(w, u.ID)
if c := h.logger.Check(zap.InfoLevel, "Update published"); c != nil {
if c := h.logger.Check(zap.DebugLevel, "Update published"); c != nil {
c.Write(zap.Object("update", u), zap.String("remote_addr", r.RemoteAddr))
}
h.metrics.UpdatePublished(u)
Expand Down
4 changes: 2 additions & 2 deletions subscribe.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ func (h *Hub) SubscribeHandler(w http.ResponseWriter, r *http.Request) {
}
heartbeatTimer.Reset(h.heartbeat)
}
if c := h.logger.Check(zap.InfoLevel, "Update sent"); c != nil {
if c := h.logger.Check(zap.DebugLevel, "Update sent"); c != nil {
c.Write(zap.Object("subscriber", s), zap.Object("update", update))
}
}
Expand All @@ -171,7 +171,7 @@ func (h *Hub) registerSubscriber(w http.ResponseWriter, r *http.Request) (*Subsc
}
if err != nil || (claims == nil && !h.anonymous) {
http.Error(w, http.StatusText(http.StatusUnauthorized), http.StatusUnauthorized)
if c := h.logger.Check(zap.InfoLevel, "Subscriber unauthorized"); c != nil {
if c := h.logger.Check(zap.DebugLevel, "Subscriber unauthorized"); c != nil {
c.Write(zap.Object("subscriber", s), zap.Error(err))
}

Expand Down

0 comments on commit f6ffafc

Please sign in to comment.