From f5c7cd16ca6265167eb416041cd9c71302d4ba59 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E7=99=BD=E8=8C=B6=E6=B8=85=E6=AC=A2?= Date: Thu, 23 Jun 2022 10:27:56 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=97=A5=E5=BF=97=E9=85=8D?= =?UTF-8?q?=E7=BD=AE=E5=A4=84=E7=90=86=E9=94=99=E8=AF=AF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- client.go | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/client.go b/client.go index 60cde99..7ef0398 100644 --- a/client.go +++ b/client.go @@ -228,14 +228,15 @@ func (c *client) getLogInstance(logConf *logger.InputLogConfig) (*zap.Logger, er var ( err error loggerInstance *zap.Logger + splitConfig *logger.RotateLogConfig ) - splitConfig := &logger.RotateLogConfig{ - TimeIntervalType: logConf.TimeIntervalType, - LogPath: logConf.Path, - LogFileName: logConf.Name, - DivisionChar: logConf.DivisionChar, - FullLogFormat: logConf.Format, - MaxAge: time.Duration(logConf.MaxAge) * time.Second, + if splitConfig, err = logger.NewRotateLogConfig( + logConf.Path, + logConf.Name, + logger.WithDivisionChar(logConf.DivisionChar), + logger.WithTimeIntervalType(logConf.TimeIntervalType), + logger.WithMaxAge(time.Duration(logConf.MaxAge)*time.Second)); nil != err { + return nil, err } if loggerInstance, err = logger.NewLogger(logConf.LogLevel, splitConfig, logConfList...); nil != err { return nil, err