fix: add config and logger, cleanup

This commit is contained in:
sajadMRjl
2026-01-28 03:07:06 +03:30
parent 5b5b992754
commit 476aa90968
9 changed files with 228 additions and 118 deletions

31
internal/logger/logger.go Normal file
View File

@@ -0,0 +1,31 @@
package logger
import (
"log/slog"
"os"
"strings"
)
// Setup initializes the global logger based on config
func Setup(level string) {
var logLevel slog.Level
switch strings.ToUpper(level) {
case "DEBUG":
logLevel = slog.LevelDebug
case "WARN":
logLevel = slog.LevelWarn
case "ERROR":
logLevel = slog.LevelError
default:
logLevel = slog.LevelInfo
}
// Create a structured text handler (easier to read than JSON in terminal)
handler := slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{
Level: logLevel,
})
logger := slog.New(handler)
slog.SetDefault(logger)
}