mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
FE logs: no handler context.
This commit is contained in:
parent
d0e283f1a9
commit
51207c2b50
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user