From cd0058dfa4ba2e2bfdd7219fe8912e12136db7b8 Mon Sep 17 00:00:00 2001 From: David Allen Date: Wed, 3 Sep 2025 17:38:41 -0600 Subject: [PATCH] fix: added logic to make directory for log file --- pkg/log/log.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/log/log.go b/pkg/log/log.go index 90ffa8d..95735b6 100644 --- a/pkg/log/log.go +++ b/pkg/log/log.go @@ -4,6 +4,7 @@ import ( "fmt" "io" "os" + "path/filepath" "slices" "strings" @@ -74,6 +75,12 @@ func InitWithLogLevel(logLevel LogLevel, logPath string) error { Level: level, }) + // make the log directory if necessary + err = os.MkdirAll(filepath.Dir(logPath), 0o777) + if err != nil { + return fmt.Errorf("failed to create log path directory: %v", err) + } + // add another writer to write to a log file if logPath != "" { LogFile, err = os.OpenFile(logPath, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0664)