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

This commit is contained in:
白茶清欢 2022-05-15 20:43:55 +08:00
parent 520bf437cd
commit 9c51e86e3a
1 changed files with 3 additions and 0 deletions

View File

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