From 35a75ea21e01fafb856ef1342700f8acda19c7d9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Sat, 14 Aug 2021 19:24:39 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20redis=20log?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- logger/config.go | 2 +- middleware/redis/client.go | 10 +++++++++- 2 files changed, 10 insertions(+), 2 deletions(-) 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..., ) }