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"
)
@ -25,14 +25,14 @@ func (c Client) ProcessServerMessages(channel chan<- GoTomato.ServerMessage) {
return
}
// Log any other errors
log.Error("Read error!", "reason", err)
helper.Logger.Error("Read error!", "reason", err)
close(channel)
return
}
err = json.Unmarshal(message, &serverMessage)
if err != nil {
log.Error("Error unmarshalling!", "reason", err)
helper.Logger.Error("Error unmarshalling!", "reason", err)
continue
}