修复不需要日志时, NPE问题

This commit is contained in:
白茶清欢 2022-05-15 20:43:55 +08:00
parent 520bf437cd
commit 9c51e86e3a

View File

@ -97,6 +97,9 @@ func getLogInstance(logConf *LogConfig, loggerInstance *zap.Logger) (*zap.Logger
if nil != loggerInstance { if nil != loggerInstance {
return loggerInstance, nil return loggerInstance, nil
} }
if nil == logConf {
return nil, nil
}
logConfList := []logger.SetLoggerOptionFunc{logger.WithEncoder(logConf.Encoder), logger.WithCallerSkip(logConf.Skip), logger.WithCaller()} logConfList := []logger.SetLoggerOptionFunc{logger.WithEncoder(logConf.Encoder), logger.WithCallerSkip(logConf.Skip), logger.WithCaller()}
if logConf.ConsoleOutput { if logConf.ConsoleOutput {
logConfList = append(logConfList, logger.WithConsoleOutput()) logConfList = append(logConfList, logger.WithConsoleOutput())