- update log

master v1.0.10
李光春 2 years ago
parent e477b71b71
commit 6b416f791d

@ -44,11 +44,11 @@ type Client struct {
mchSslKey string // pem key 内容 mchSslKey string // pem key 内容
} }
log struct { log struct {
gormClient *dorm.GormClient // 日志数据库
gorm bool // 日志开关 gorm bool // 日志开关
gormClient *dorm.GormClient // 日志数据库
logGormClient *golog.ApiClient // 日志服务 logGormClient *golog.ApiClient // 日志服务
mongoClient *dorm.MongoClient // 日志数据库
mongo bool // 日志开关 mongo bool // 日志开关
mongoClient *dorm.MongoClient // 日志数据库
logMongoClient *golog.ApiClient // 日志服务 logMongoClient *golog.ApiClient // 日志服务
} }
} }
@ -71,7 +71,7 @@ func NewClient(config *ClientConfig) (*Client, error) {
c.requestClient = gorequest.NewHttp() c.requestClient = gorequest.NewHttp()
gormClient := config.GormClientFun() gormClient := config.GormClientFun()
if gormClient.Db != nil { if gormClient != nil && gormClient.Db != nil {
c.log.logGormClient, err = golog.NewApiGormClient(func() (*dorm.GormClient, string) { c.log.logGormClient, err = golog.NewApiGormClient(func() (*dorm.GormClient, string) {
return gormClient, logTable return gormClient, logTable
}, config.Debug) }, config.Debug)
@ -79,11 +79,11 @@ func NewClient(config *ClientConfig) (*Client, error) {
return nil, err return nil, err
} }
c.log.gorm = true c.log.gorm = true
c.log.gormClient = gormClient
} }
c.log.gormClient = gormClient
mongoClient, databaseName := config.MongoClientFun() 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) { c.log.logMongoClient, err = golog.NewApiMongoClient(func() (*dorm.MongoClient, string, string) {
return mongoClient, databaseName, logTable return mongoClient, databaseName, logTable
}, config.Debug) }, config.Debug)
@ -91,8 +91,8 @@ func NewClient(config *ClientConfig) (*Client, error) {
return nil, err return nil, err
} }
c.log.mongo = true c.log.mongo = true
c.log.mongoClient = mongoClient
} }
c.log.mongoClient = mongoClient
return c, nil return c, nil
} }

@ -14,7 +14,7 @@ const (
// SDK 相关信息 // SDK 相关信息
const ( const (
Version = "1.0.9" // SDK 版本 Version = "1.0.10" // SDK 版本
UserAgentFormat = "WechatPay-Go/%s (%s) GO/%s" // UserAgent中的信息 UserAgentFormat = "WechatPay-Go/%s (%s) GO/%s" // UserAgent中的信息
) )

@ -40,10 +40,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) 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) go c.log.logMongoClient.MongoMiddleware(ctx, request, Version)
} }

Loading…
Cancel
Save