修复issues #1118 (#1119)

* - 修复issues #1118
- zap日志无法按照等级出现在对应log文件中
- zap.AddCaller()只有在global.GVA_CONFIG.Zap.ShowLine为true才生效
- rotatelogs.ForceNewFile(),取消这个, 这样每次启动不会出现同一天日志级别.1后缀的新文件

* 等级使用Transport进行转换,优化臃肿代码,优雅获取zapcore.Core
This commit is contained in:
SliverHorn
2022-06-10 09:57:25 +08:00
committed by GitHub
parent 582c39611d
commit 9da394f711
4 changed files with 156 additions and 88 deletions

View File

@@ -18,7 +18,6 @@ type fileRotatelogs struct{}
func (r *fileRotatelogs) GetWriteSyncer(level string) (zapcore.WriteSyncer, error) {
fileWriter, err := rotatelogs.New(
path.Join(global.GVA_CONFIG.Zap.Director, "%Y-%m-%d", level+".log"),
rotatelogs.ForceNewFile(),
rotatelogs.WithClock(rotatelogs.Local),
rotatelogs.WithMaxAge(time.Duration(global.GVA_CONFIG.Zap.MaxAge)*24*time.Hour), // 日志留存时间
rotatelogs.WithRotationTime(time.Hour*24),