mirror of
https://github.com/m1k1o/neko.git
synced 2025-05-11 16:17:31 +02:00
websockets set max payload log size. (#42)
This commit is contained in:
parent
2ff47ac920
commit
43a649d2c4
2 changed files with 22 additions and 6 deletions
|
@ -12,6 +12,7 @@ import (
|
|||
"github.com/demodesk/neko/pkg/types"
|
||||
"github.com/demodesk/neko/pkg/types/event"
|
||||
"github.com/demodesk/neko/pkg/types/message"
|
||||
"github.com/demodesk/neko/pkg/utils"
|
||||
)
|
||||
|
||||
type WebSocketPeerCtx struct {
|
||||
|
@ -60,11 +61,18 @@ func (peer *WebSocketPeerCtx) Send(event string, payload any) {
|
|||
return
|
||||
}
|
||||
|
||||
peer.logger.Debug().
|
||||
Str("address", peer.connection.RemoteAddr().String()).
|
||||
Str("event", event).
|
||||
Str("payload", string(raw)).
|
||||
Msg("sending message to client")
|
||||
// log events if not ignored
|
||||
if ok, _ := utils.ArrayIn(event, nologEvents); !ok {
|
||||
if len(raw) > maxPayloadLogLength {
|
||||
raw = []byte("<truncated>")
|
||||
}
|
||||
|
||||
peer.logger.Debug().
|
||||
Str("address", peer.connection.RemoteAddr().String()).
|
||||
Str("event", event).
|
||||
Str("payload", string(raw)).
|
||||
Msg("sending message to client")
|
||||
}
|
||||
}
|
||||
|
||||
func (peer *WebSocketPeerCtx) Ping() error {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue