From 1371d49b980a61e398125784e381b61678499265 Mon Sep 17 00:00:00 2001 From: nicoxiang <916592561@qq.com> Date: Sun, 27 Oct 2024 20:18:40 +0800 Subject: [PATCH] fix log bug --- internal/pkg/logger/logger.go | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/internal/pkg/logger/logger.go b/internal/pkg/logger/logger.go index 1689254..fbc4d2c 100644 --- a/internal/pkg/logger/logger.go +++ b/internal/pkg/logger/logger.go @@ -43,7 +43,12 @@ func (f *customFormatter) Format(entry *logrus.Entry) ([]byte, error) { func init() { userConfigDir, _ := os.UserConfigDir() - logFilePath := filepath.Join(userConfigDir, GeektimeLogFolder, GeektimeLogFolder+".log") + logDir := filepath.Join(userConfigDir, GeektimeLogFolder) + logFilePath := filepath.Join(logDir, GeektimeLogFolder+".log") + + if err := os.MkdirAll(logDir, 0755); err != nil { + logger.Fatalf("Failed to create log directory: %v", err) + } logger.SetReportCaller(true) logger.SetLevel(logrus.InfoLevel)