feat: replace standard log with charmbracelet/log
- update logging to use charmbracelet/log package
- improve log messages for server start and errors
- enhance client connection and disconnection logs
🤖
This commit is contained in:
parent
3eae584d6d
commit
899417b605
7 changed files with 68 additions and 15 deletions
|
@ -5,8 +5,8 @@ import (
|
|||
"git.smsvc.net/pomodoro/GoTomato/internal/pomodoro"
|
||||
"git.smsvc.net/pomodoro/GoTomato/internal/shared"
|
||||
"git.smsvc.net/pomodoro/GoTomato/pkg/models"
|
||||
"github.com/charmbracelet/log"
|
||||
"github.com/gorilla/websocket"
|
||||
"log"
|
||||
)
|
||||
|
||||
// handleClientCommands listens for commands from WebSocket clients
|
||||
|
@ -16,7 +16,7 @@ func handleClientCommands(ws *websocket.Conn) {
|
|||
|
||||
_, message, err := ws.ReadMessage()
|
||||
if err != nil {
|
||||
log.Printf("Client disconnected from %s (%v) (total: %d)", ws.NetConn().RemoteAddr(), err, len(Clients)-1)
|
||||
log.Info("Client disconnected:", "msg", err, "host", ws.NetConn().RemoteAddr(), "clients", len(Clients)-1)
|
||||
delete(Clients, ws)
|
||||
break
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ func handleClientCommands(ws *websocket.Conn) {
|
|||
// Handle incoming commands
|
||||
err = json.Unmarshal(message, &clientCommand)
|
||||
if err != nil {
|
||||
log.Printf("Error unmarshalling command: %v", err)
|
||||
log.Error("Error unmarshalling command:", "msg", err)
|
||||
continue
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue