ws handler simplify logging.

This commit is contained in:
Miroslav Šedivý 2022-01-30 17:47:28 +01:00
parent fcc85aa9d6
commit f6eb8d0315

View File

@ -34,11 +34,6 @@ type MessageHandlerCtx struct {
} }
func (h *MessageHandlerCtx) Message(session types.Session, data types.WebSocketMessage) bool { func (h *MessageHandlerCtx) Message(session types.Session, data types.WebSocketMessage) bool {
logger := h.logger.With().
Str("event", data.Event).
Str("session_id", session.ID()).
Logger()
var err error var err error
switch data.Event { switch data.Event {
// System Events // System Events
@ -146,7 +141,10 @@ func (h *MessageHandlerCtx) Message(session types.Session, data types.WebSocketM
} }
if err != nil { if err != nil {
logger.Warn().Err(err).Msg("message handler has failed") h.logger.Warn().Err(err).
Str("event", data.Event).
Str("session_id", session.ID()).
Msg("message handler has failed")
} }
return true return true