From 6b151eb0c5f0a06e871cfa581ca700bf14bef434 Mon Sep 17 00:00:00 2001 From: NeilClack Date: Sat, 25 Apr 2026 19:06:37 -0500 Subject: [PATCH] Disable DEBUG logs unless explicitly enabled --- internal/logger/logger.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/internal/logger/logger.go b/internal/logger/logger.go index 7db09ea..4609f90 100644 --- a/internal/logger/logger.go +++ b/internal/logger/logger.go @@ -25,9 +25,10 @@ func (l Level) String() string { } var ( - DB *gorm.DB - file *os.File - console = log.New(os.Stderr, "", 0) + DB *gorm.DB + file *os.File + console = log.New(os.Stderr, "", 0) + SetLevel Level = LevelInfo ) // AddFile attaches or replaces the file backend @@ -36,7 +37,7 @@ func AddFile(path string) error { file.Close() } - _, err := os.OpenFile(path, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) + _, err := os.OpenFile(path, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0o644) if err != nil { return err } @@ -61,6 +62,9 @@ func Close() error { } func logMsg(level Level, format string, args ...any) { + if level == LevelDebug && SetLevel != LevelDebug { + return + } message := fmt.Sprintf(format, args...) now := time.Now() timestamp := now.Format("2006-01-02 15:04:05.000")