Fix trace logging

This commit is contained in:
binwiederhier 2023-02-13 13:20:05 -05:00
parent 9b118e8085
commit 355424c0da

View file

@ -325,7 +325,7 @@ func (s *Server) handle(w http.ResponseWriter, r *http.Request) {
return return
} }
if log.IsTrace() { if logvr(v, r).IsTrace() {
logvr(v, r).Field("http_request", renderHTTPRequest(r)).Trace("HTTP request started") logvr(v, r).Field("http_request", renderHTTPRequest(r)).Trace("HTTP request started")
} else if log.IsDebug() { } else if log.IsDebug() {
logvr(v, r).Debug("HTTP request started") logvr(v, r).Debug("HTTP request started")
@ -628,20 +628,18 @@ func (s *Server) handlePublishWithoutResponse(r *http.Request, v *visitor) (*mes
m.Message = emptyMessageBody m.Message = emptyMessageBody
} }
delayed := m.Time > time.Now().Unix() delayed := m.Time > time.Now().Unix()
logvrm(v, r, m). ev := logvrm(v, r, m).
Tag(tagPublish). Tag(tagPublish).
Fields(log.Context{ Fields(log.Context{
"message_delayed": delayed, "message_delayed": delayed,
"message_firebase": firebase, "message_firebase": firebase,
"message_unifiedpush": unifiedpush, "message_unifiedpush": unifiedpush,
"message_email": email, "message_email": email,
}). })
Debug("Received message") if ev.IsTrace() {
if log.IsTrace() { ev.Field("message_body", util.MaybeMarshalJSON(m)).Trace("Received message")
logvrm(v, r, m). } else if ev.IsDebug() {
Tag(tagPublish). ev.Debug("Received message")
Field("message_body", util.MaybeMarshalJSON(m)).
Trace("Message body")
} }
if !delayed { if !delayed {
if err := t.Publish(v, m); err != nil { if err := t.Publish(v, m); err != nil {