支持所有日志等级
							parent
							
								
									1e65ade93f
								
							
						
					
					
						commit
						e7dfeffb3a
					
				| 
						 | 
					@ -25,12 +25,14 @@ type Config struct {
 | 
				
			||||||
	InfoLog    LogFileConfig // Info日志配置
 | 
						InfoLog    LogFileConfig // Info日志配置
 | 
				
			||||||
	WarnLog    LogFileConfig // Warn日志配置
 | 
						WarnLog    LogFileConfig // Warn日志配置
 | 
				
			||||||
	ErrorLog   LogFileConfig // Error日志配置
 | 
						ErrorLog   LogFileConfig // Error日志配置
 | 
				
			||||||
 | 
						DPanicLog  LogFileConfig // DPanic日志配置
 | 
				
			||||||
 | 
						PanicLog   LogFileConfig // Panic日志配置
 | 
				
			||||||
	FatalLog   LogFileConfig // Fatal日志配置
 | 
						FatalLog   LogFileConfig // Fatal日志配置
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
var cfg_default = Config{
 | 
					var cfg_default = Config{
 | 
				
			||||||
	DebugLog: LogFileConfig{
 | 
						DebugLog: LogFileConfig{
 | 
				
			||||||
		Filename:    "./log/log",
 | 
							Filename:    "./log/Info",
 | 
				
			||||||
		FileSize_MB: 5,
 | 
							FileSize_MB: 5,
 | 
				
			||||||
		FileBackup:  5,
 | 
							FileBackup:  5,
 | 
				
			||||||
		FileAge_DAY: 30,
 | 
							FileAge_DAY: 30,
 | 
				
			||||||
| 
						 | 
					@ -69,6 +71,8 @@ func configDefault(config ...Config) Config {
 | 
				
			||||||
	applyDefaults(&cfg.InfoLog, &cfg_default.DebugLog)
 | 
						applyDefaults(&cfg.InfoLog, &cfg_default.DebugLog)
 | 
				
			||||||
	applyDefaults(&cfg.WarnLog, &cfg_default.DebugLog)
 | 
						applyDefaults(&cfg.WarnLog, &cfg_default.DebugLog)
 | 
				
			||||||
	applyDefaults(&cfg.ErrorLog, &cfg_default.DebugLog)
 | 
						applyDefaults(&cfg.ErrorLog, &cfg_default.DebugLog)
 | 
				
			||||||
 | 
						applyDefaults(&cfg.DPanicLog, &cfg_default.DebugLog)
 | 
				
			||||||
 | 
						applyDefaults(&cfg.PanicLog, &cfg_default.DebugLog)
 | 
				
			||||||
	applyDefaults(&cfg.FatalLog, &cfg_default.DebugLog)
 | 
						applyDefaults(&cfg.FatalLog, &cfg_default.DebugLog)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	return cfg
 | 
						return cfg
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -118,6 +118,12 @@ func New(config ...Config) *zap.SugaredLogger {
 | 
				
			||||||
	if cfg.Mode <= Error {
 | 
						if cfg.Mode <= Error {
 | 
				
			||||||
		coreArr = append(coreArr, createCore(zap.ErrorLevel, cfg.ErrorLog))
 | 
							coreArr = append(coreArr, createCore(zap.ErrorLevel, cfg.ErrorLog))
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
						if cfg.Mode <= DPanic {
 | 
				
			||||||
 | 
							coreArr = append(coreArr, createCore(zap.DPanicLevel, cfg.DPanicLog))
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
 | 
						if cfg.Mode <= Panic {
 | 
				
			||||||
 | 
							coreArr = append(coreArr, createCore(zap.PanicLevel, cfg.PanicLog))
 | 
				
			||||||
 | 
						}
 | 
				
			||||||
	if cfg.Mode <= Fatal {
 | 
						if cfg.Mode <= Fatal {
 | 
				
			||||||
		coreArr = append(coreArr, createCore(zap.FatalLevel, cfg.FatalLog))
 | 
							coreArr = append(coreArr, createCore(zap.FatalLevel, cfg.FatalLog))
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
		Reference in New Issue