From bda5c8a1763cb164336a289a21b1e974cff1c303 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=85=89=E6=98=A5?= Date: Wed, 28 Dec 2022 15:06:49 +0800 Subject: [PATCH] - update log --- CHANGELOG.md | 6 +++- library.go | 2 +- utils/golog/api.go | 73 ++++++++++++++++++++++++---------------------- utils/golog/gin.go | 62 ++++++++++++++++++--------------------- 4 files changed, 73 insertions(+), 70 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 2d6647fe..f68812a2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,7 +1,11 @@ +## v2022-12-28 + +- update log + ## v2022-12-23 - meituan:update api -- string:update +- string:update ## v2022-12-19 diff --git a/library.go b/library.go index 96722cea..16e167ab 100644 --- a/library.go +++ b/library.go @@ -1,5 +1,5 @@ package go_library func Version() string { - return "1.0.61" + return "1.0.62" } diff --git a/utils/golog/api.go b/utils/golog/api.go index 23da01ab..910d5fae 100644 --- a/utils/golog/api.go +++ b/utils/golog/api.go @@ -73,9 +73,12 @@ func NewApiClient(config *ApiClientConfig) (*ApiClient, error) { c.setConfig(ctx) gormClient, gormTableName := config.GormClientFun() - mongoClient, mongoDatabaseName, mongoCollectionName := config.MongoClientFun() + //mongoClient, mongoDatabaseName, mongoCollectionName := config.MongoClientFun() - if (gormClient == nil || gormClient.GetDb() == nil) || (mongoClient == nil || mongoClient.GetDb() == nil) { + //if (gormClient == nil || gormClient.GetDb() == nil) || (mongoClient == nil || mongoClient.GetDb() == nil) { + // return nil, dbClientFunNoConfig + //} + if gormClient == nil || gormClient.GetDb() == nil { return nil, dbClientFunNoConfig } @@ -97,30 +100,30 @@ func NewApiClient(config *ApiClientConfig) (*ApiClient, error) { } // 配置非关系数据库 - if mongoClient != nil || mongoClient.GetDb() != nil { - - c.mongoClient = mongoClient - - if mongoDatabaseName == "" { - return nil, errors.New("没有设置库名") - } else { - c.mongoConfig.databaseName = mongoDatabaseName - } - - if mongoCollectionName == "" { - return nil, errors.New("没有设置表名") - } else { - c.mongoConfig.collectionName = mongoCollectionName - } - - // 创建时间序列集合 - c.mongoCreateCollection(ctx) - - // 创建索引 - c.mongoCreateIndexes(ctx) - - c.mongoConfig.stats = true - } + //if mongoClient != nil || mongoClient.GetDb() != nil { + // + // c.mongoClient = mongoClient + // + // if mongoDatabaseName == "" { + // return nil, errors.New("没有设置库名") + // } else { + // c.mongoConfig.databaseName = mongoDatabaseName + // } + // + // if mongoCollectionName == "" { + // return nil, errors.New("没有设置表名") + // } else { + // c.mongoConfig.collectionName = mongoCollectionName + // } + // + // // 创建时间序列集合 + // c.mongoCreateCollection(ctx) + // + // // 创建索引 + // c.mongoCreateIndexes(ctx) + // + // c.mongoConfig.stats = true + //} return c, nil } @@ -130,9 +133,9 @@ func (c *ApiClient) Middleware(ctx context.Context, request gorequest.Response, if c.gormConfig.stats { c.gormMiddleware(ctx, request, sdkVersion) } - if c.mongoConfig.stats { - c.mongoMiddleware(ctx, request, sdkVersion) - } + //if c.mongoConfig.stats { + // c.mongoMiddleware(ctx, request, sdkVersion) + //} } // MiddlewareXml 中间件 @@ -140,9 +143,9 @@ func (c *ApiClient) MiddlewareXml(ctx context.Context, request gorequest.Respons if c.gormConfig.stats { c.gormMiddlewareXml(ctx, request, sdkVersion) } - if c.mongoConfig.stats { - c.mongoMiddlewareXml(ctx, request, sdkVersion) - } + //if c.mongoConfig.stats { + // c.mongoMiddlewareXml(ctx, request, sdkVersion) + //} } // MiddlewareCustom 中间件 @@ -150,7 +153,7 @@ func (c *ApiClient) MiddlewareCustom(ctx context.Context, api string, request go if c.gormConfig.stats { c.gormMiddlewareCustom(ctx, api, request, sdkVersion) } - if c.mongoConfig.stats { - c.mongoMiddlewareCustom(ctx, api, request, sdkVersion) - } + //if c.mongoConfig.stats { + // c.mongoMiddlewareCustom(ctx, api, request, sdkVersion) + //} } diff --git a/utils/golog/gin.go b/utils/golog/gin.go index 792dc2fc..38f11e9d 100644 --- a/utils/golog/gin.go +++ b/utils/golog/gin.go @@ -83,9 +83,12 @@ func NewGinClient(config *GinClientConfig) (*GinClient, error) { c.setConfig(ctx) gormClient, gormTableName := config.GormClientFun() - mongoClient, mongoDatabaseName, mongoCollectionName := config.MongoClientFun() + //mongoClient, mongoDatabaseName, mongoCollectionName := config.MongoClientFun() - if (gormClient == nil || gormClient.GetDb() == nil) || (mongoClient == nil || mongoClient.GetDb() == nil) { + //if (gormClient == nil || gormClient.GetDb() == nil) || (mongoClient == nil || mongoClient.GetDb() == nil) { + // return nil, dbClientFunNoConfig + //} + if gormClient == nil || gormClient.GetDb() == nil { return nil, dbClientFunNoConfig } @@ -106,30 +109,30 @@ func NewGinClient(config *GinClientConfig) (*GinClient, error) { } // 配置非关系数据库 - if mongoClient != nil || mongoClient.GetDb() != nil { - - c.mongoClient = mongoClient - - if mongoDatabaseName == "" { - return nil, errors.New("没有设置库名") - } else { - c.mongoConfig.databaseName = mongoDatabaseName - } - - if mongoCollectionName == "" { - return nil, errors.New("没有设置表名") - } else { - c.mongoConfig.collectionName = mongoCollectionName - } - - // 创建时间序列集合 - //c.mongoCreateCollection(ctx) - - // 创建索引 - c.mongoCreateIndexes(ctx) - - c.mongoConfig.stats = true - } + //if mongoClient != nil || mongoClient.GetDb() != nil { + // + // c.mongoClient = mongoClient + // + // if mongoDatabaseName == "" { + // return nil, errors.New("没有设置库名") + // } else { + // c.mongoConfig.databaseName = mongoDatabaseName + // } + // + // if mongoCollectionName == "" { + // return nil, errors.New("没有设置表名") + // } else { + // c.mongoConfig.collectionName = mongoCollectionName + // } + // + // // 创建时间序列集合 + // //c.mongoCreateCollection(ctx) + // + // // 创建索引 + // c.mongoCreateIndexes(ctx) + // + // c.mongoConfig.stats = true + //} return c, nil } @@ -213,13 +216,6 @@ func (c *GinClient) Middleware() gin.HandlerFunc { c.gormRecordXml(ginCtx, traceId, requestTime, data, responseCode, responseBody, startTime, endTime, info) } } - if c.mongoConfig.stats { - if dataJson { - c.mongoRecordJson(ginCtx, traceId, requestTime, data, responseCode, responseBody, startTime, endTime, info) - } else { - c.mongoRecordXml(ginCtx, traceId, requestTime, data, responseCode, responseBody, startTime, endTime, info) - } - } }() } }