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,10 +2,10 @@ package websocket
|
|||
|
||||
import (
|
||||
"encoding/json"
|
||||
"github.com/charmbracelet/log"
|
||||
"github.com/gorilla/websocket"
|
||||
"time"
|
||||
|
||||
"git.smsvc.net/pomodoro/GoTomato/internal/helper"
|
||||
"git.smsvc.net/pomodoro/GoTomato/internal/shared"
|
||||
)
|
||||
|
||||
|
@ -16,14 +16,14 @@ func SendPermanentBroadCastMessage() {
|
|||
// Marshal the message into JSON format
|
||||
jsonMessage, err := json.Marshal(shared.State)
|
||||
if err != nil {
|
||||
log.Error("Error marshalling message:", "msg", err)
|
||||
helper.Logger.Error("Error marshalling message:", "msg", err)
|
||||
return
|
||||
}
|
||||
// Iterate over all connected clients and broadcast the message
|
||||
for _, client := range Clients {
|
||||
err := client.SendMessage(websocket.TextMessage, jsonMessage)
|
||||
if err != nil {
|
||||
log.Error("Error broadcasting to client:", "msg", err)
|
||||
helper.Logger.Error("Error broadcasting to client:", "msg", err)
|
||||
// The client is responsible for closing itself on error
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue