Replace all log.Println and fmt.Printf with Zap structured logging

This commit is contained in:
2026-05-21 23:24:55 +02:00
parent f0653489d6
commit 89c31c2856
7 changed files with 184 additions and 162 deletions
+6 -5
View File
@@ -1,21 +1,22 @@
package backend
import (
"fmt"
"log"
"os"
"strings"
"music-server/internal/logging"
"go.uber.org/zap"
)
func GetCharacterList() []string {
charactersPath := os.Getenv("CHARACTERS_PATH")
fmt.Printf("dir: %s\n", charactersPath)
logging.GetLogger().Debug("Getting character list", zap.String("path", charactersPath))
if !strings.HasSuffix(charactersPath, "/") {
charactersPath += "/"
}
files, err := os.ReadDir(charactersPath)
if err != nil {
log.Fatal(err)
logging.GetLogger().Fatal("Failed to read characters directory", zap.String("path", charactersPath), zap.String("error", err.Error()))
}
var characters []string
@@ -29,7 +30,7 @@ func GetCharacterList() []string {
func GetCharacter(character string) string {
charactersPath := os.Getenv("CHARACTERS_PATH")
fmt.Printf("dir: %s\n", charactersPath)
logging.GetLogger().Debug("Getting character", zap.String("character", character), zap.String("path", charactersPath))
if !strings.HasSuffix(charactersPath, "/") {
charactersPath += "/"
}