- update log

master v1.0.12
李光春 2 years ago
parent f4d0e5875b
commit 323c12f565

@ -30,11 +30,11 @@ type Client struct {
customerKey string // 商家密钥
}
log struct {
gormClient *dorm.GormClient // 日志数据库
gorm bool // 日志开关
gormClient *dorm.GormClient // 日志数据库
logGormClient *golog.ApiClient // 日志服务
mongoClient *dorm.MongoClient // 日志数据库
mongo bool // 日志开关
mongoClient *dorm.MongoClient // 日志数据库
logMongoClient *golog.ApiClient // 日志服务
}
}
@ -51,7 +51,7 @@ func NewClient(config *ClientConfig) (*Client, error) {
c.requestClient = gorequest.NewHttp()
gormClient := config.GormClientFun()
if gormClient.Db != nil {
if gormClient != nil && gormClient.Db != nil {
c.log.logGormClient, err = golog.NewApiGormClient(func() (*dorm.GormClient, string) {
return gormClient, logTable
}, config.Debug)
@ -59,11 +59,11 @@ func NewClient(config *ClientConfig) (*Client, error) {
return nil, err
}
c.log.gorm = true
c.log.gormClient = gormClient
}
c.log.gormClient = gormClient
mongoClient, databaseName := config.MongoClientFun()
if mongoClient.Db != nil {
if mongoClient != nil && mongoClient.Db != nil {
c.log.logMongoClient, err = golog.NewApiMongoClient(func() (*dorm.MongoClient, string, string) {
return mongoClient, databaseName, logTable
}, config.Debug)
@ -71,8 +71,8 @@ func NewClient(config *ClientConfig) (*Client, error) {
return nil, err
}
c.log.mongo = true
c.log.mongoClient = mongoClient
}
c.log.mongoClient = mongoClient
return c, nil
}

@ -17,4 +17,4 @@ const (
logTable = "kashangwl"
)
const Version = "1.0.11"
const Version = "1.0.12"

@ -34,10 +34,10 @@ func (c *Client) request(ctx context.Context, url string, params map[string]inte
}
// 日志
if c.log.gorm == true {
if c.log.gorm {
go c.log.logGormClient.GormMiddleware(ctx, request, Version)
}
if c.log.mongo == true {
if c.log.mongo {
go c.log.logMongoClient.MongoMiddleware(ctx, request, Version)
}
@ -68,10 +68,10 @@ func (c *Client) requestCache(ctx context.Context, url string, params map[string
}
// 日志
if c.log.gorm == true {
if c.log.gorm {
go c.log.logGormClient.GormMiddleware(ctx, request, Version)
}
if c.log.mongo == true {
if c.log.mongo {
go c.log.logMongoClient.MongoMiddleware(ctx, request, Version)
}

Loading…
Cancel
Save