infra: add logging wrapping
Resolves issues with gcp cloud logging quirks such as field names
This commit is contained in:
@@ -2,13 +2,14 @@ package pusher
|
||||
|
||||
import (
|
||||
"context"
|
||||
"log/slog"
|
||||
"net/http"
|
||||
|
||||
"github.com/flowy-live/llink/genproto/llink/pusher"
|
||||
"github.com/flowy-live/llink/internal/auth"
|
||||
"github.com/google/uuid"
|
||||
"nhooyr.io/websocket"
|
||||
|
||||
pbpusher "github.com/flowy-live/llink/genproto/llink/pusher"
|
||||
"github.com/flowy-live/llink/internal/auth"
|
||||
"github.com/flowy-live/llink/internal/utils/flog"
|
||||
)
|
||||
|
||||
// Server handles WebSocket upgrades and gRPC presence queries.
|
||||
@@ -49,14 +50,14 @@ func (s *Server) HandleWebSocket(w http.ResponseWriter, r *http.Request) {
|
||||
InsecureSkipVerify: true,
|
||||
})
|
||||
if err != nil {
|
||||
slog.Error("websocket accept failed", "error", err)
|
||||
flog.Error("websocket accept failed", "error", err)
|
||||
return
|
||||
}
|
||||
|
||||
connID := uuid.New().String()
|
||||
conn := newConn(connID, session.HumanId, ws)
|
||||
|
||||
slog.Info("websocket connected", "connId", connID, "humanId", session.HumanId)
|
||||
flog.Info("websocket connected", "connId", connID, "humanId", session.HumanId)
|
||||
|
||||
// Use the server context, not r.Context(): after upgrade the HTTP request
|
||||
// context can be cancelled by load balancers and nhooyr/websocket would
|
||||
@@ -70,7 +71,7 @@ func (s *Server) HandleWebSocket(w http.ResponseWriter, r *http.Request) {
|
||||
go conn.WritePump(ctx)
|
||||
conn.ReadPump(ctx, s.hub)
|
||||
|
||||
slog.Info("websocket disconnected", "connId", connID, "humanId", session.HumanId)
|
||||
flog.Info("websocket disconnected", "connId", connID, "humanId", session.HumanId)
|
||||
}
|
||||
|
||||
func (s *Server) GetOnlineHumanIds(ctx context.Context, _ *pbpusher.GetOnlineHumanIdsRequest) (*pbpusher.GetOnlineHumanIdsResponse, error) {
|
||||
|
||||
Reference in New Issue
Block a user