增加获取日志实例方法
This commit is contained in:
parent
9f1337a668
commit
70b47647e9
26
client.go
26
client.go
@ -114,6 +114,32 @@ func (c *client) GetSlaveClient(ctx *gin.Context, dbFlag string) (*gorm.DB, erro
|
|||||||
return session, nil
|
return session, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// getLogInstance 获取日志实例
|
||||||
|
//
|
||||||
|
// Author : go_developer@163.com<白茶清欢>
|
||||||
|
//
|
||||||
|
// Date : 20:23 2022/6/5
|
||||||
|
func (c *client) getLogInstance(logConf *LogConfig, loggerInstance *zap.Logger) (*zap.Logger, error) {
|
||||||
|
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())
|
||||||
|
}
|
||||||
|
|
||||||
|
var (
|
||||||
|
err error
|
||||||
|
)
|
||||||
|
if loggerInstance, err = logger.NewLogger(logConf.Level, logConf.SplitConfig, logConfList...); nil != err {
|
||||||
|
return nil, err
|
||||||
|
}
|
||||||
|
return loggerInstance, nil
|
||||||
|
}
|
||||||
|
|
||||||
// BatchNewDBClient 批量设置数据库实例, 读取指定目录下的yaml文件, 文件名作为标识, 内容是数据库具体配置
|
// BatchNewDBClient 批量设置数据库实例, 读取指定目录下的yaml文件, 文件名作为标识, 内容是数据库具体配置
|
||||||
//
|
//
|
||||||
// Author : go_developer@163.com<白茶清欢>
|
// Author : go_developer@163.com<白茶清欢>
|
||||||
|
Loading…
Reference in New Issue
Block a user