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:
Sebastian Mark 2024-11-03 22:22:03 +01:00
parent ebc81657f5
commit 561419b568
6 changed files with 24 additions and 14 deletions

View file

@ -2,9 +2,9 @@ package websocket
import (
"encoding/json"
"github.com/charmbracelet/log"
"github.com/gorilla/websocket"
"git.smsvc.net/pomodoro/ChronoTomato/internal/helper"
GoTomato "git.smsvc.net/pomodoro/GoTomato/pkg/models"
)
@ -12,13 +12,13 @@ import (
func sendClientCommand(c Client, msg GoTomato.ClientCommand) {
messageBytes, err := json.Marshal(msg)
if err != nil {
log.Error("Error marshalling!", "reason", err)
helper.Logger.Error("Error marshalling!", "reason", err)
return
}
err = c.Conn.WriteMessage(websocket.TextMessage, messageBytes)
if err != nil {
log.Error("Write error!", "reason", err)
helper.Logger.Error("Write error!", "reason", err)
return
}
}