修复日志切割规则构建错误问题
This commit is contained in:
parent
3f63f6c673
commit
e536831e80
19
define.go
19
define.go
@ -8,9 +8,10 @@
|
||||
package logger
|
||||
|
||||
import (
|
||||
"time"
|
||||
|
||||
"go.uber.org/zap"
|
||||
"go.uber.org/zap/zapcore"
|
||||
"time"
|
||||
)
|
||||
|
||||
// InputLogConfig 输入的日志配置
|
||||
@ -21,7 +22,6 @@ import (
|
||||
type InputLogConfig struct {
|
||||
Name string `json:"name" yaml:"name"` // 日志文件名
|
||||
Path string `json:"path" yaml:"path"` // 日志文件路径
|
||||
Format string `json:"format" yaml:"format"` // 文件格式
|
||||
TimeIntervalType TimeIntervalType `json:"time_interval_type" yaml:"time_interval_type"` // 日志切割规则
|
||||
DivisionChar string `json:"division_char" yaml:"division_char"` // 文件名分隔符
|
||||
LogLevel zapcore.Level `json:"log_level" yaml:"log_level"` // 日志等级
|
||||
@ -59,14 +59,15 @@ func GetLogInstanceFromInputConfig(logConf *InputLogConfig) (*zap.Logger, error)
|
||||
var (
|
||||
err error
|
||||
loggerInstance *zap.Logger
|
||||
splitConfig *RotateLogConfig
|
||||
)
|
||||
splitConfig := &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 = NewRotateLogConfig(
|
||||
logConf.Path,
|
||||
logConf.Name,
|
||||
WithDivisionChar(logConf.DivisionChar),
|
||||
WithTimeIntervalType(logConf.TimeIntervalType),
|
||||
WithMaxAge(time.Duration(logConf.MaxAge)*time.Second)); nil != err {
|
||||
return nil, err
|
||||
}
|
||||
if loggerInstance, err = NewLogger(logConf.LogLevel, splitConfig, logConfList...); nil != err {
|
||||
return nil, err
|
||||
|
Loading…
Reference in New Issue
Block a user