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