From f4fd37c55165a80876f4d29bae2a82c83c42c1fd Mon Sep 17 00:00:00 2001 From: Sebastian Mark Date: Wed, 30 Oct 2024 10:19:07 +0100 Subject: [PATCH] feat: update logging for client connect and disconnect MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - update logging to use ws.RemoteAddr() 🤖 --- internal/websocket/client_commands.go | 2 +- internal/websocket/handle_connection.go | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/internal/websocket/client_commands.go b/internal/websocket/client_commands.go index b38e55b..60158f2 100644 --- a/internal/websocket/client_commands.go +++ b/internal/websocket/client_commands.go @@ -17,7 +17,7 @@ func handleClientCommands(c models.WebsocketClient) { _, message, err := ws.ReadMessage() if err != nil { - log.Info("Client disconnected:", "msg", err, "host", ws.NetConn().RemoteAddr(), "clients", len(Clients)-1) + log.Info("Client disconnected:", "msg", err, "host", ws.RemoteAddr(), "clients", len(Clients)-1) delete(Clients, ws.LocalAddr()) break } diff --git a/internal/websocket/handle_connection.go b/internal/websocket/handle_connection.go index b7b240f..6abb339 100644 --- a/internal/websocket/handle_connection.go +++ b/internal/websocket/handle_connection.go @@ -29,7 +29,7 @@ func HandleConnection(w http.ResponseWriter, r *http.Request) { } defer ws.Close() - log.Info("Client connected", "host", ws.NetConn().RemoteAddr(), "clients", len(Clients)+1) + log.Info("Client connected", "host", ws.RemoteAddr(), "clients", len(Clients)+1) // Register the new client client := models.WebsocketClient{