From 62238574cbdb79eb4d070786e63103fa26cccfca Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Adrian=20Z=C3=BCrcher?= Date: Fri, 12 Dec 2025 10:01:11 +0100 Subject: [PATCH] change empty filepath to executable name --- logging/logging.go | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/logging/logging.go b/logging/logging.go index 99fab46..416866d 100644 --- a/logging/logging.go +++ b/logging/logging.go @@ -3,6 +3,8 @@ package logging import ( "fmt" "os" + "path/filepath" + "strings" "time" "go.uber.org/zap" @@ -32,7 +34,8 @@ func NewLogger(file string, cfg *Config) (*Logger, error) { } if file == "" { - file = "NewLogger.log" + file = os.Args[0] + file = strings.Replace(filepath.Base(file), filepath.Ext(file), ".log", 1) } encoderConfig := zap.NewProductionEncoderConfig() @@ -44,9 +47,9 @@ func NewLogger(file string, cfg *Config) (*Logger, error) { fileSyncer := zapcore.AddSync(&lumberjack.Logger{ Filename: file, - MaxSize: 1, // megabytes - MaxBackups: 3, - MaxAge: 28, // days + MaxSize: cfg.MaxSize, // megabytes + MaxBackups: cfg.MaxBackup, + MaxAge: cfg.MaxAge, // days }) // Create core list