FE logs: no handler context.

This commit is contained in:
Miroslav Šedivý 2021-09-09 22:51:37 +02:00
parent d0e283f1a9
commit 51207c2b50

View File

@ -4,6 +4,7 @@ import (
"errors" "errors"
"github.com/rs/zerolog" "github.com/rs/zerolog"
"github.com/rs/zerolog/log"
"demodesk/neko/internal/types" "demodesk/neko/internal/types"
"demodesk/neko/internal/types/event" "demodesk/neko/internal/types/event"
@ -84,14 +85,19 @@ func (h *MessageHandlerCtx) systemAdmin(session types.Session) error {
} }
func (h *MessageHandlerCtx) systemLogs(session types.Session, payload *message.SystemLogs) error { func (h *MessageHandlerCtx) systemLogs(session types.Session, payload *message.SystemLogs) error {
for _, log := range *payload { for _, msg := range *payload {
level, _ := zerolog.ParseLevel(log.Level) level, _ := zerolog.ParseLevel(msg.Level)
h.logger.WithLevel(level). if level < zerolog.DebugLevel || level > zerolog.ErrorLevel {
Fields(log.Fields). level = zerolog.NoLevel
}
// do not use handler logger context
log.WithLevel(level).
Fields(msg.Fields).
Str("session_id", session.ID()). Str("session_id", session.ID()).
Str("service", "frontend"). Str("service", "frontend").
Msg(log.Message) Msg(msg.Message)
} }
return nil return nil