forked from tangled.org/core
this repo has no description

knotserver: reduce logging noise from event stream

Signed-off-by: oppiliappan <me@oppi.li>

oppi.li c16a1338 f2b6ba26

verified
Changed files
+6 -6
knotserver
+6 -6
knotserver/events.go
···
func (h *Handle) Events(w http.ResponseWriter, r *http.Request) {
l := h.l.With("handler", "OpLog")
-
l.Info("received new connection")
+
l.Debug("received new connection")
conn, err := upgrader.Upgrade(w, r, nil)
if err != nil {
···
return
}
defer conn.Close()
-
l.Info("upgraded http to wss")
+
l.Debug("upgraded http to wss")
ch := h.n.Subscribe()
defer h.n.Unsubscribe(ch)
···
cursor := r.URL.Query().Get("cursor")
// complete backfill first before going to live data
-
l.Info("going through backfill", "cursor", cursor)
+
l.Debug("going through backfill", "cursor", cursor)
if err := h.streamOps(conn, &cursor); err != nil {
l.Error("failed to backfill", "err", err)
return
···
// wait for new data or timeout
select {
case <-ctx.Done():
-
l.Info("stopping stream: client closed connection")
+
l.Debug("stopping stream: client closed connection")
return
case <-ch:
// we have been notified of new data
-
l.Info("going through live data", "cursor", cursor)
+
l.Debug("going through live data", "cursor", cursor)
if err := h.streamOps(conn, &cursor); err != nil {
l.Error("failed to stream", "err", err)
return
}
case <-time.After(30 * time.Second):
// send a keep-alive
-
l.Info("sent keepalive")
+
l.Debug("sent keepalive")
if err = conn.WriteControl(websocket.PingMessage, []byte{}, time.Now().Add(time.Second)); err != nil {
l.Error("failed to write control", "err", err)
}