feat: implement centralized logging helper
- remove direct log usage
- create a new logging helper
- update all log calls to use the new Logger instance
- set timestamp to ISO8601
🤖
This commit is contained in:
parent
76f3954299
commit
600d2ed2ff
6 changed files with 30 additions and 17 deletions
|
@ -2,8 +2,8 @@ package websocket
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/charmbracelet/log"
|
||||
|
||||
"git.smsvc.net/pomodoro/GoTomato/internal/helper"
|
||||
"git.smsvc.net/pomodoro/GoTomato/internal/pomodoro"
|
||||
"git.smsvc.net/pomodoro/GoTomato/internal/shared"
|
||||
"git.smsvc.net/pomodoro/GoTomato/pkg/models"
|
||||
|
@ -22,14 +22,14 @@ func handleClientCommands(c models.WebsocketClient) {
|
|||
_, message, err := ws.ReadMessage()
|
||||
if err != nil {
|
||||
delete(Clients, ws.LocalAddr())
|
||||
log.Info("Client disconnected:", "msg", err, "host", c.RealIP, "clients", len(Clients))
|
||||
helper.Logger.Info("Client disconnected:", "msg", err, "host", c.RealIP, "clients", len(Clients))
|
||||
break
|
||||
}
|
||||
|
||||
// Handle incoming commands
|
||||
err = json.Unmarshal(message, &clientCommand)
|
||||
if err != nil {
|
||||
log.Error("Error unmarshalling command:", "msg", err)
|
||||
helper.Logger.Error("Error unmarshalling command:", "msg", err)
|
||||
continue
|
||||
}
|
||||
|
||||
|
@ -55,10 +55,10 @@ func handleClientCommands(c models.WebsocketClient) {
|
|||
case "updateSettings":
|
||||
if !pomodoro.IsPomodoroOngoing() {
|
||||
if !checkSettings(clientCommand.Settings) {
|
||||
log.Warn("Ignoring invalid config:", "msg", clientCommand.Settings, "host", c.Conn.RemoteAddr())
|
||||
helper.Logger.Warn("Ignoring invalid config:", "msg", clientCommand.Settings, "host", c.Conn.RemoteAddr())
|
||||
break
|
||||
}
|
||||
log.Info("Client send config", "config", clientCommand.Settings, "host", c.Conn.RemoteAddr())
|
||||
helper.Logger.Info("Client send config", "config", clientCommand.Settings, "host", c.Conn.RemoteAddr())
|
||||
pomodoro.UpdateSettings(clientCommand.Settings)
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue