diff --git a/logger/config.go b/logger/config.go index 24ea0ee..2c34459 100644 --- a/logger/config.go +++ b/logger/config.go @@ -52,7 +52,7 @@ type RotateLogConfig struct { MaxAge time.Duration `json:"max_age" yaml:"max_age"` // 日志最长保存时间 } -// SetRotateLogConfigOption 设置日志切割的选项 +// SetRotateLogConfigFunc 设置日志切割的选项 // // Author : go_developer@163.com<白茶清欢> // diff --git a/middleware/redis/client.go b/middleware/redis/client.go index 7b4ef9b..422bb57 100644 --- a/middleware/redis/client.go +++ b/middleware/redis/client.go @@ -150,9 +150,17 @@ func (c *Client) getLogger(conf *LoggerConfig) (*zap.Logger, error) { if conf.Encoder != nil { optionFuncList = append(optionFuncList, logger.WithEncoder(conf.Encoder)) } + + splitConfigFuncList := []logger.SetRotateLogConfigFunc{ + logger.WithTimeIntervalType(conf.SplitConfig.TimeIntervalType), + logger.WithDivisionChar(conf.SplitConfig.DivisionChar), + logger.WithMaxAge(conf.SplitConfig.MaxAge), + } + + splitConfig, _ := logger.NewRotateLogConfig(conf.SplitConfig.LogPath, conf.SplitConfig.LogFileName, splitConfigFuncList...) return logger.NewLogger( conf.LoggerLevel, - conf.SplitConfig, + splitConfig, optionFuncList..., ) }