feat: improve logging for client connects and disconnects
- add connection log to record client address on connect
- enhance disconnection log to include client address
🤖
This commit is contained in:
parent
f991ba885d
commit
c6ce7d46ad
2 changed files with 3 additions and 1 deletions
|
@ -18,7 +18,7 @@ func handleClientCommands(ws *websocket.Conn) {
|
|||
|
||||
_, message, err := ws.ReadMessage()
|
||||
if err != nil {
|
||||
log.Printf("Client disconnected: %v", err)
|
||||
log.Printf("Client disconnected from %s (%v)", ws.NetConn().RemoteAddr(), err)
|
||||
delete(Clients, ws)
|
||||
break
|
||||
}
|
||||
|
|
|
@ -27,6 +27,8 @@ func HandleConnections(w http.ResponseWriter, r *http.Request) {
|
|||
}
|
||||
defer ws.Close()
|
||||
|
||||
log.Printf("Client connected from %v", ws.NetConn().RemoteAddr())
|
||||
|
||||
// Register the new client
|
||||
mu.Lock()
|
||||
Clients[ws] = &models.Client{
|
||||
|
|
Loading…
Reference in a new issue