From 49df014426bbcf336f52da75085a4abef39f0121 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9D=8E=E5=85=89=E6=98=A5?= Date: Sun, 4 Jun 2023 17:59:36 +0800 Subject: [PATCH] - update log --- library.go | 2 +- service/alipayopen/client.go | 4 - service/alipayopen/config.go | 9 -- service/alipayopen/get.go | 6 - service/alipayopen/request.go | 3 - service/amap/client.go | 4 - service/amap/config.go | 9 -- service/amap/get.go | 6 - service/amap/request.go | 3 - service/baidu/client.go | 4 - service/baidu/config.go | 9 -- service/baidu/get.go | 6 - service/baidu/request.go | 3 - service/caiyunapp/client.go | 4 - service/caiyunapp/config.go | 9 -- service/caiyunapp/get.go | 6 - service/caiyunapp/request.go | 3 - service/cloudflare/client.go | 26 +---- service/cloudflare/request.go | 15 +-- service/dingdanxia/client.go | 4 - service/dingdanxia/config.go | 9 -- service/dingdanxia/get.go | 6 - service/dingdanxia/request.go | 3 - service/dingtalk/client.go | 4 - service/dingtalk/config.go | 9 -- service/dingtalk/get.go | 6 - service/dingtalk/request.go | 3 - service/douyin/client.go | 4 - service/douyin/config.go | 9 -- service/douyin/get.go | 6 - service/douyin/request.go | 3 - service/eastiot/client.go | 4 - service/eastiot/config.go | 9 -- service/eastiot/get.go | 6 - service/eastiot/request.go | 3 - service/ejiaofei/client.go | 4 - service/ejiaofei/config.go | 9 -- service/ejiaofei/get.go | 6 - service/ejiaofei/request.go | 3 - service/feishu/client.go | 4 - service/feishu/config.go | 9 -- service/feishu/get.go | 6 - service/feishu/request.go | 3 - service/gddata/client.go | 5 - service/gddata/config.go | 11 -- service/gddata/request.go | 3 - service/gitee/client.go | 16 +-- service/gitee/request.go | 3 - service/jd/client.go | 4 - service/jd/config.go | 9 -- service/jd/get.go | 6 - service/jd/request.go | 3 - service/kashangwl/client.go | 9 -- service/kashangwl/config.go | 11 -- service/kashangwl/get.go | 6 - service/kashangwl/request.go | 10 +- service/kuaishou/client.go | 4 - service/kuaishou/cofnig.go | 9 -- service/kuaishou/get.go | 6 - service/leshuazf/client.go | 4 - service/leshuazf/config.go | 9 -- service/leshuazf/get.go | 6 +- service/leshuazf/request.go | 3 - service/meituan/client.go | 4 - service/meituan/config.go | 9 -- service/meituan/get.go | 6 - service/meituan/request.go | 3 - service/nldyp/client.go | 4 - service/nldyp/request.go | 3 - service/pconline/client.go | 6 +- service/pconline/config.go | 9 -- service/pconline/request.go | 3 - service/pinduoduo/client.go | 4 - service/pinduoduo/config.go | 9 -- service/pinduoduo/get.go | 6 - service/pinduoduo/request.go | 3 - service/pintoto/client.go | 4 - service/pintoto/config.go | 9 -- service/pintoto/get.go | 6 - service/pintoto/request.go | 3 - service/qiniu/client.go | 5 - service/qq/client.go | 4 - service/qq/config.go | 9 -- service/qq/get.go | 6 - service/qq/request.go | 3 - service/sendcloud/client.go | 4 - service/sendcloud/config.go | 9 -- service/sendcloud/get.go | 4 +- service/sendcloud/request.go | 3 - service/taobao/client.go | 4 - service/taobao/config.go | 9 -- service/taobao/get.go | 6 - service/taobao/request.go | 3 - service/wechatminiprogram/client.go | 4 - service/wechatminiprogram/config.go | 9 -- service/wechatminiprogram/get.go | 5 - service/wechatminiprogram/request.go | 3 - service/wechatoffice/client.go | 4 - service/wechatoffice/config.go | 9 -- service/wechatoffice/get.go | 5 - service/wechatoffice/request.go | 3 - service/wechatopen/client.go | 4 - service/wechatopen/config.go | 9 -- service/wechatopen/get.go | 5 - service/wechatopen/request.go | 3 - service/wechatpayapiv2/client.go | 4 - service/wechatpayapiv2/config.go | 9 -- service/wechatpayapiv2/get.go | 5 - service/wechatpayapiv2/request.go | 3 - service/wechatpayapiv3/client.go | 4 - service/wechatpayapiv3/config.go | 9 -- service/wechatpayapiv3/get.go | 6 - service/wechatpayapiv3/request.go | 3 - service/wechatpayopen/client.go | 4 - service/wechatpayopen/config.go | 9 -- service/wechatpayopen/get.go | 6 - service/wechatpayopen/request.go | 3 - service/wechatqy/client.go | 4 - service/wechatqy/config.go | 9 -- service/wechatqy/get.go | 6 - service/wechatqy/request.go | 3 - service/wechatunion/client.go | 4 - service/wechatunion/config.go | 9 -- service/wechatunion/get.go | 5 - service/wechatunion/request.go | 3 - service/weishi/client.go | 4 - service/weishi/config.go | 9 -- service/weishi/get.go | 6 - service/weishi/request.go | 3 - service/wikeyun/client.go | 4 - service/wikeyun/config.go | 9 -- service/wikeyun/get.go | 6 - service/wikeyun/request.go | 3 - service/wnfuwu/client.go | 4 - service/wnfuwu/config.go | 9 -- service/wnfuwu/get.go | 6 - service/wnfuwu/request.go | 3 - utils/golog/api.go | 112 ------------------- utils/golog/api_cofing.go | 28 ----- utils/golog/api_gorm.go | 157 --------------------------- utils/golog/error.go | 2 +- utils/golog/gin.go | 9 +- 142 files changed, 24 insertions(+), 1081 deletions(-) delete mode 100644 utils/golog/api.go delete mode 100644 utils/golog/api_cofing.go delete mode 100644 utils/golog/api_gorm.go diff --git a/library.go b/library.go index 9549b7d3..67c61548 100644 --- a/library.go +++ b/library.go @@ -1,5 +1,5 @@ package go_library func Version() string { - return "1.0.151" + return "1.0.152" } diff --git a/service/alipayopen/client.go b/service/alipayopen/client.go index 361348f8..99fd6d08 100644 --- a/service/alipayopen/client.go +++ b/service/alipayopen/client.go @@ -30,10 +30,6 @@ type Client struct { alipayRSA2 string // 支付宝公钥 aes string // 接口内容加密方式 } - log struct { - status bool // 状态 - client *golog.ApiClient // 日志服务 - } zap struct { status bool // 状态 client *golog.ApiZapLog // 日志服务 diff --git a/service/alipayopen/config.go b/service/alipayopen/config.go index 790a5931..9784ced2 100644 --- a/service/alipayopen/config.go +++ b/service/alipayopen/config.go @@ -2,15 +2,6 @@ package alipayopen import "github.com/dtapps/go-library/utils/golog" -// ConfigApiClientFun 日志配置 -func (c *Client) ConfigApiClientFun(apiClientFun golog.ApiClientFun) { - apiClient := apiClientFun() - if apiClient != nil { - c.log.client = apiClient - c.log.status = true - } -} - // ConfigZapClientFun 日志配置 func (c *Client) ConfigZapClientFun(apiZapLogFun golog.ApiZapLogFun) { apiZapLog := apiZapLogFun() diff --git a/service/alipayopen/get.go b/service/alipayopen/get.go index 9fd370b7..0d9dded2 100644 --- a/service/alipayopen/get.go +++ b/service/alipayopen/get.go @@ -1,7 +1,5 @@ package alipayopen -import "github.com/dtapps/go-library/utils/golog" - func (c *Client) GetAppId() string { return c.config.appId } @@ -21,7 +19,3 @@ func (c *Client) GetAlipayRSA2() string { func (c *Client) GetAes() string { return c.config.aes } - -func (c *Client) GetLog() *golog.ApiClient { - return c.log.client -} diff --git a/service/alipayopen/request.go b/service/alipayopen/request.go index db1de02c..f5de943b 100644 --- a/service/alipayopen/request.go +++ b/service/alipayopen/request.go @@ -27,9 +27,6 @@ func (c *Client) request(ctx context.Context, param map[string]interface{}) (gor } // 记录日志 - if c.log.status { - go c.log.client.MiddlewareCustom(ctx, gostring.ToString(params["method"]), request) - } if c.zap.status { go c.zap.client.MiddlewareCustom(ctx, gostring.ToString(params["method"]), request) } diff --git a/service/amap/client.go b/service/amap/client.go index 779121e5..ead61afd 100644 --- a/service/amap/client.go +++ b/service/amap/client.go @@ -16,10 +16,6 @@ type Client struct { config struct { key string } - log struct { - status bool // 状态 - client *golog.ApiClient // 日志服务 - } zap struct { status bool // 状态 client *golog.ApiZapLog // 日志服务 diff --git a/service/amap/config.go b/service/amap/config.go index 2f26c8d9..39759a18 100644 --- a/service/amap/config.go +++ b/service/amap/config.go @@ -2,15 +2,6 @@ package amap import "github.com/dtapps/go-library/utils/golog" -// ConfigApiClientFun 日志配置 -func (c *Client) ConfigApiClientFun(apiClientFun golog.ApiClientFun) { - apiClient := apiClientFun() - if apiClient != nil { - c.log.client = apiClient - c.log.status = true - } -} - // ConfigZapClientFun 日志配置 func (c *Client) ConfigZapClientFun(apiZapLogFun golog.ApiZapLogFun) { apiZapLog := apiZapLogFun() diff --git a/service/amap/get.go b/service/amap/get.go index c8a6013f..213511b0 100644 --- a/service/amap/get.go +++ b/service/amap/get.go @@ -1,11 +1,5 @@ package amap -import "github.com/dtapps/go-library/utils/golog" - func (c *Client) GetKey() string { return c.config.key } - -func (c *Client) GetLog() *golog.ApiClient { - return c.log.client -} diff --git a/service/amap/request.go b/service/amap/request.go index dd8057c5..d493397b 100644 --- a/service/amap/request.go +++ b/service/amap/request.go @@ -29,9 +29,6 @@ func (c *Client) request(ctx context.Context, url string, params map[string]inte } // 记录日志 - if c.log.status { - go c.log.client.Middleware(ctx, request) - } if c.zap.status { go c.zap.client.Middleware(ctx, request) } diff --git a/service/baidu/client.go b/service/baidu/client.go index 906e6806..103ed10f 100644 --- a/service/baidu/client.go +++ b/service/baidu/client.go @@ -14,10 +14,6 @@ type Client struct { config struct { ak string } - log struct { - status bool // 状态 - client *golog.ApiClient // 日志服务 - } zap struct { status bool // 状态 client *golog.ApiZapLog // 日志服务 diff --git a/service/baidu/config.go b/service/baidu/config.go index 7d17d5f7..697b5f33 100644 --- a/service/baidu/config.go +++ b/service/baidu/config.go @@ -2,15 +2,6 @@ package baidu import "github.com/dtapps/go-library/utils/golog" -// ConfigApiClientFun 日志配置 -func (c *Client) ConfigApiClientFun(apiClientFun golog.ApiClientFun) { - apiClient := apiClientFun() - if apiClient != nil { - c.log.client = apiClient - c.log.status = true - } -} - // ConfigZapClientFun 日志配置 func (c *Client) ConfigZapClientFun(apiZapLogFun golog.ApiZapLogFun) { apiZapLog := apiZapLogFun() diff --git a/service/baidu/get.go b/service/baidu/get.go index a92f30d2..538cc40d 100644 --- a/service/baidu/get.go +++ b/service/baidu/get.go @@ -1,11 +1,5 @@ package baidu -import "github.com/dtapps/go-library/utils/golog" - func (c *Client) GetAk() string { return c.config.ak } - -func (c *Client) GetLog() *golog.ApiClient { - return c.log.client -} diff --git a/service/baidu/request.go b/service/baidu/request.go index 0fb205dc..02a98a58 100644 --- a/service/baidu/request.go +++ b/service/baidu/request.go @@ -29,9 +29,6 @@ func (c *Client) request(ctx context.Context, url string, params map[string]inte } // 记录日志 - if c.log.status { - go c.log.client.Middleware(ctx, request) - } if c.zap.status { go c.zap.client.Middleware(ctx, request) } diff --git a/service/caiyunapp/client.go b/service/caiyunapp/client.go index 3f4c0586..a6c71bfb 100644 --- a/service/caiyunapp/client.go +++ b/service/caiyunapp/client.go @@ -16,10 +16,6 @@ type Client struct { config struct { token string } - log struct { - status bool // 状态 - client *golog.ApiClient // 日志服务 - } zap struct { status bool // 状态 client *golog.ApiZapLog // 日志服务 diff --git a/service/caiyunapp/config.go b/service/caiyunapp/config.go index ed4ce68a..327ebd23 100644 --- a/service/caiyunapp/config.go +++ b/service/caiyunapp/config.go @@ -2,15 +2,6 @@ package caiyunapp import "github.com/dtapps/go-library/utils/golog" -// ConfigApiClientFun 日志配置 -func (c *Client) ConfigApiClientFun(apiClientFun golog.ApiClientFun) { - apiClient := apiClientFun() - if apiClient != nil { - c.log.client = apiClient - c.log.status = true - } -} - // ConfigZapClientFun 日志配置 func (c *Client) ConfigZapClientFun(apiZapLogFun golog.ApiZapLogFun) { apiZapLog := apiZapLogFun() diff --git a/service/caiyunapp/get.go b/service/caiyunapp/get.go index febfd765..d1bba9b2 100644 --- a/service/caiyunapp/get.go +++ b/service/caiyunapp/get.go @@ -1,15 +1,9 @@ package caiyunapp -import "github.com/dtapps/go-library/utils/golog" - func (c *Client) GetToken() string { return c.config.token } -func (c *Client) GetLog() *golog.ApiClient { - return c.log.client -} - func (c *Client) getApiUrl() string { return apiUrl + "/" + c.config.token } diff --git a/service/caiyunapp/request.go b/service/caiyunapp/request.go index c4c6a7cc..b40df655 100644 --- a/service/caiyunapp/request.go +++ b/service/caiyunapp/request.go @@ -29,9 +29,6 @@ func (c *Client) request(ctx context.Context, url string, params map[string]inte } // 记录日志 - if c.log.status { - go c.log.client.Middleware(ctx, request) - } if c.zap.status { go c.zap.client.Middleware(ctx, request) } diff --git a/service/cloudflare/client.go b/service/cloudflare/client.go index f17b53fd..b5b41d90 100644 --- a/service/cloudflare/client.go +++ b/service/cloudflare/client.go @@ -2,7 +2,6 @@ package cloudflare import ( "github.com/dtapps/go-library/utils/dorm" - "github.com/dtapps/go-library/utils/golog" "github.com/dtapps/go-library/utils/gorequest" "gorm.io/gorm" ) @@ -17,9 +16,8 @@ type ConfigClient struct { } type Client struct { - client *gorequest.App // 请求客户端 - log *golog.ApiClient // 日志服务 - config *ConfigClient // 配置 + client *gorequest.App // 请求客户端 + config *ConfigClient // 配置 } func NewClient(config *ConfigClient) (*Client, error) { @@ -29,25 +27,5 @@ func NewClient(config *ConfigClient) (*Client, error) { c.client = gorequest.NewHttp() - if c.config.PgsqlDb != nil { - c.log, err = golog.NewApiClient( - golog.WithGormClient(c.config.PgsqlDb), - golog.WithTableName(logTable), - ) - if err != nil { - return nil, err - } - } - if c.config.MongoDb != nil { - c.log, err = golog.NewApiClient( - golog.WithMongoClient(c.config.MongoDb), - golog.WithDatabaseName(c.config.DatabaseName), - golog.WithCollectionName(logTable), - ) - if err != nil { - return nil, err - } - } - return c, nil } diff --git a/service/cloudflare/request.go b/service/cloudflare/request.go index 0acd30a6..08eed38f 100644 --- a/service/cloudflare/request.go +++ b/service/cloudflare/request.go @@ -1,8 +1,11 @@ package cloudflare -import "github.com/dtapps/go-library/utils/gorequest" +import ( + "context" + "github.com/dtapps/go-library/utils/gorequest" +) -func (c *Client) request(url string, params map[string]interface{}, method string) (gorequest.Response, error) { +func (c *Client) request(ctx context.Context, url string, params map[string]interface{}, method string) (gorequest.Response, error) { // 创建请求 client := c.client @@ -20,18 +23,12 @@ func (c *Client) request(url string, params map[string]interface{}, method strin client.SetParams(params) // 发起请求 - request, err := client.Request() + request, err := client.Request(ctx) if err != nil { return gorequest.Response{}, err } // 日志 - if c.config.PgsqlDb != nil { - go c.log.GormMiddleware(request) - } - if c.config.MongoDb != nil { - go c.log.MongoMiddleware(request) - } return request, err } diff --git a/service/dingdanxia/client.go b/service/dingdanxia/client.go index 622c4148..bfab1f99 100644 --- a/service/dingdanxia/client.go +++ b/service/dingdanxia/client.go @@ -16,10 +16,6 @@ type Client struct { config struct { apiKey string // 密钥 } - log struct { - status bool // 状态 - client *golog.ApiClient // 日志服务 - } zap struct { status bool // 状态 client *golog.ApiZapLog // 日志服务 diff --git a/service/dingdanxia/config.go b/service/dingdanxia/config.go index 984ba3f3..0d4e156f 100644 --- a/service/dingdanxia/config.go +++ b/service/dingdanxia/config.go @@ -2,15 +2,6 @@ package dingdanxia import "github.com/dtapps/go-library/utils/golog" -// ConfigApiClientFun 日志配置 -func (c *Client) ConfigApiClientFun(apiClientFun golog.ApiClientFun) { - apiClient := apiClientFun() - if apiClient != nil { - c.log.client = apiClient - c.log.status = true - } -} - // ConfigZapClientFun 日志配置 func (c *Client) ConfigZapClientFun(apiZapLogFun golog.ApiZapLogFun) { apiZapLog := apiZapLogFun() diff --git a/service/dingdanxia/get.go b/service/dingdanxia/get.go index 6e8229bc..345b1ba4 100644 --- a/service/dingdanxia/get.go +++ b/service/dingdanxia/get.go @@ -1,11 +1,5 @@ package dingdanxia -import "github.com/dtapps/go-library/utils/golog" - func (c *Client) GetApiKey() string { return c.config.apiKey } - -func (c *Client) GetLog() *golog.ApiClient { - return c.log.client -} diff --git a/service/dingdanxia/request.go b/service/dingdanxia/request.go index 08ea008a..c488f83e 100644 --- a/service/dingdanxia/request.go +++ b/service/dingdanxia/request.go @@ -33,9 +33,6 @@ func (c *Client) request(ctx context.Context, url string, params map[string]inte } // 记录日志 - if c.log.status { - go c.log.client.Middleware(ctx, request) - } if c.zap.status { go c.zap.client.Middleware(ctx, request) } diff --git a/service/dingtalk/client.go b/service/dingtalk/client.go index 259e3745..b1a3dd34 100644 --- a/service/dingtalk/client.go +++ b/service/dingtalk/client.go @@ -18,10 +18,6 @@ type Client struct { secret string accessToken string } - log struct { - status bool // 状态 - client *golog.ApiClient // 日志服务 - } zap struct { status bool // 状态 client *golog.ApiZapLog // 日志服务 diff --git a/service/dingtalk/config.go b/service/dingtalk/config.go index c67d0bb7..732bc5a7 100644 --- a/service/dingtalk/config.go +++ b/service/dingtalk/config.go @@ -8,15 +8,6 @@ func (c *Client) Config(secret, accessToken string) *Client { return c } -// ConfigApiClientFun 日志配置 -func (c *Client) ConfigApiClientFun(apiClientFun golog.ApiClientFun) { - apiClient := apiClientFun() - if apiClient != nil { - c.log.client = apiClient - c.log.status = true - } -} - // ConfigZapClientFun 日志配置 func (c *Client) ConfigZapClientFun(apiZapLogFun golog.ApiZapLogFun) { apiZapLog := apiZapLogFun() diff --git a/service/dingtalk/get.go b/service/dingtalk/get.go index 23a4eac4..24acec1f 100644 --- a/service/dingtalk/get.go +++ b/service/dingtalk/get.go @@ -1,7 +1,5 @@ package dingtalk -import "github.com/dtapps/go-library/utils/golog" - func (c *Client) GetSecret() string { return c.config.secret } @@ -9,7 +7,3 @@ func (c *Client) GetSecret() string { func (c *Client) GetAccessToken() string { return c.config.accessToken } - -func (c *Client) GetLog() *golog.ApiClient { - return c.log.client -} diff --git a/service/dingtalk/request.go b/service/dingtalk/request.go index 912ad25c..b41de1b3 100644 --- a/service/dingtalk/request.go +++ b/service/dingtalk/request.go @@ -29,9 +29,6 @@ func (c *Client) request(ctx context.Context, url string, params map[string]inte } // 记录日志 - if c.log.status { - go c.log.client.Middleware(ctx, request) - } if c.zap.status { go c.zap.client.Middleware(ctx, request) } diff --git a/service/douyin/client.go b/service/douyin/client.go index 6b94bdfe..03d42afc 100644 --- a/service/douyin/client.go +++ b/service/douyin/client.go @@ -14,10 +14,6 @@ type Client struct { config struct { ua string // 用户代理 } - log struct { - status bool // 状态 - client *golog.ApiClient // 日志服务 - } zap struct { status bool // 状态 client *golog.ApiZapLog // 日志服务 diff --git a/service/douyin/config.go b/service/douyin/config.go index 644f2b92..573b3f4c 100644 --- a/service/douyin/config.go +++ b/service/douyin/config.go @@ -2,15 +2,6 @@ package douyin import "github.com/dtapps/go-library/utils/golog" -// ConfigApiClientFun 日志配置 -func (c *Client) ConfigApiClientFun(apiClientFun golog.ApiClientFun) { - apiClient := apiClientFun() - if apiClient != nil { - c.log.client = apiClient - c.log.status = true - } -} - // ConfigZapClientFun 日志配置 func (c *Client) ConfigZapClientFun(apiZapLogFun golog.ApiZapLogFun) { apiZapLog := apiZapLogFun() diff --git a/service/douyin/get.go b/service/douyin/get.go index 105f1bc3..efd23129 100644 --- a/service/douyin/get.go +++ b/service/douyin/get.go @@ -1,7 +1 @@ package douyin - -import "github.com/dtapps/go-library/utils/golog" - -func (c *Client) GetLog() *golog.ApiClient { - return c.log.client -} diff --git a/service/douyin/request.go b/service/douyin/request.go index 14744741..919aab65 100644 --- a/service/douyin/request.go +++ b/service/douyin/request.go @@ -32,9 +32,6 @@ func (c *Client) request(ctx context.Context, url string, params map[string]inte } // 记录日志 - if c.log.status { - go c.log.client.Middleware(ctx, request) - } if c.zap.status { go c.zap.client.Middleware(ctx, request) } diff --git a/service/eastiot/client.go b/service/eastiot/client.go index 9a168044..5186f4fc 100644 --- a/service/eastiot/client.go +++ b/service/eastiot/client.go @@ -18,10 +18,6 @@ type Client struct { appId string apiKey string } - log struct { - status bool // 状态 - client *golog.ApiClient // 日志服务 - } zap struct { status bool // 状态 client *golog.ApiZapLog // 日志服务 diff --git a/service/eastiot/config.go b/service/eastiot/config.go index 16d5cade..f3e2ab2b 100644 --- a/service/eastiot/config.go +++ b/service/eastiot/config.go @@ -2,15 +2,6 @@ package eastiot import "github.com/dtapps/go-library/utils/golog" -// ConfigApiClientFun 日志配置 -func (c *Client) ConfigApiClientFun(apiClientFun golog.ApiClientFun) { - apiClient := apiClientFun() - if apiClient != nil { - c.log.client = apiClient - c.log.status = true - } -} - // ConfigZapClientFun 日志配置 func (c *Client) ConfigZapClientFun(apiZapLogFun golog.ApiZapLogFun) { apiZapLog := apiZapLogFun() diff --git a/service/eastiot/get.go b/service/eastiot/get.go index 2ce94bcc..9d730690 100644 --- a/service/eastiot/get.go +++ b/service/eastiot/get.go @@ -1,7 +1,5 @@ package eastiot -import "github.com/dtapps/go-library/utils/golog" - func (c *Client) GetAppId() string { return c.config.appId } @@ -9,7 +7,3 @@ func (c *Client) GetAppId() string { func (c *Client) GetApiKey() string { return c.config.apiKey } - -func (c *Client) GetLog() *golog.ApiClient { - return c.log.client -} diff --git a/service/eastiot/request.go b/service/eastiot/request.go index 0765dab8..f2b57280 100644 --- a/service/eastiot/request.go +++ b/service/eastiot/request.go @@ -37,9 +37,6 @@ func (c *Client) request(ctx context.Context, url string, params map[string]inte } // 记录日志 - if c.log.status { - go c.log.client.Middleware(ctx, request) - } if c.zap.status { go c.zap.client.Middleware(ctx, request) } diff --git a/service/ejiaofei/client.go b/service/ejiaofei/client.go index 18e244a3..e1fc449f 100644 --- a/service/ejiaofei/client.go +++ b/service/ejiaofei/client.go @@ -21,10 +21,6 @@ type Client struct { key string signStr string // 需要签名的字符串 } - log struct { - status bool // 状态 - client *golog.ApiClient // 日志服务 - } zap struct { status bool // 状态 client *golog.ApiZapLog // 日志服务 diff --git a/service/ejiaofei/config.go b/service/ejiaofei/config.go index 1d5f8ec7..2bc22ebc 100644 --- a/service/ejiaofei/config.go +++ b/service/ejiaofei/config.go @@ -2,15 +2,6 @@ package ejiaofei import "github.com/dtapps/go-library/utils/golog" -// ConfigApiClientFun 日志配置 -func (c *Client) ConfigApiClientFun(apiClientFun golog.ApiClientFun) { - apiClient := apiClientFun() - if apiClient != nil { - c.log.client = apiClient - c.log.status = true - } -} - // ConfigZapClientFun 日志配置 func (c *Client) ConfigZapClientFun(apiZapLogFun golog.ApiZapLogFun) { apiZapLog := apiZapLogFun() diff --git a/service/ejiaofei/get.go b/service/ejiaofei/get.go index a95f564c..ec733384 100644 --- a/service/ejiaofei/get.go +++ b/service/ejiaofei/get.go @@ -1,7 +1,5 @@ package ejiaofei -import "github.com/dtapps/go-library/utils/golog" - func (c *Client) GetUserId() string { return c.config.userId } @@ -13,7 +11,3 @@ func (c *Client) GetPwd() string { func (c *Client) GetKey() string { return c.config.key } - -func (c *Client) GetLog() *golog.ApiClient { - return c.log.client -} diff --git a/service/ejiaofei/request.go b/service/ejiaofei/request.go index 27cd6606..77c59f97 100644 --- a/service/ejiaofei/request.go +++ b/service/ejiaofei/request.go @@ -38,9 +38,6 @@ func (c *Client) request(ctx context.Context, url string, params map[string]inte } // 记录日志 - if c.log.status { - go c.log.client.MiddlewareXml(ctx, request) - } if c.zap.status { go c.zap.client.MiddlewareXml(ctx, request) } diff --git a/service/feishu/client.go b/service/feishu/client.go index 3461bba3..bc797eda 100644 --- a/service/feishu/client.go +++ b/service/feishu/client.go @@ -16,10 +16,6 @@ type Client struct { config struct { key string } - log struct { - status bool // 状态 - client *golog.ApiClient // 日志服务 - } zap struct { status bool // 状态 client *golog.ApiZapLog // 日志服务 diff --git a/service/feishu/config.go b/service/feishu/config.go index de5e23ee..d915d0b9 100644 --- a/service/feishu/config.go +++ b/service/feishu/config.go @@ -7,15 +7,6 @@ func (c *Client) Config(key string) *Client { return c } -// ConfigApiClientFun 日志配置 -func (c *Client) ConfigApiClientFun(apiClientFun golog.ApiClientFun) { - apiClient := apiClientFun() - if apiClient != nil { - c.log.client = apiClient - c.log.status = true - } -} - // ConfigZapClientFun 日志配置 func (c *Client) ConfigZapClientFun(apiZapLogFun golog.ApiZapLogFun) { apiZapLog := apiZapLogFun() diff --git a/service/feishu/get.go b/service/feishu/get.go index ac2caeb0..56a81c1e 100644 --- a/service/feishu/get.go +++ b/service/feishu/get.go @@ -1,11 +1,5 @@ package feishu -import "github.com/dtapps/go-library/utils/golog" - func (c *Client) GetKey() string { return c.config.key } - -func (c *Client) GetLog() *golog.ApiClient { - return c.log.client -} diff --git a/service/feishu/request.go b/service/feishu/request.go index 0d78aad9..dbeb80e5 100644 --- a/service/feishu/request.go +++ b/service/feishu/request.go @@ -26,9 +26,6 @@ func (c *Client) request(ctx context.Context, url string, params map[string]inte } // 记录日志 - if c.log.status { - go c.log.client.Middleware(ctx, request) - } if c.zap.status { go c.zap.client.Middleware(ctx, request) } diff --git a/service/gddata/client.go b/service/gddata/client.go index 31a3d7f6..81d101d1 100644 --- a/service/gddata/client.go +++ b/service/gddata/client.go @@ -1,7 +1,6 @@ package gddata import ( - "github.com/dtapps/go-library/utils/golog" "github.com/dtapps/go-library/utils/gorequest" ) @@ -16,10 +15,6 @@ type Client struct { config struct { token string } - log struct { - status bool // 状态 - client *golog.ApiClient // 日志服务 - } } // NewClient 创建实例化 diff --git a/service/gddata/config.go b/service/gddata/config.go index 28097553..1bfdbaf5 100644 --- a/service/gddata/config.go +++ b/service/gddata/config.go @@ -1,17 +1,6 @@ package gddata -import "github.com/dtapps/go-library/utils/golog" - func (c *Client) Config(token string) *Client { c.config.token = token return c } - -// ConfigApiClientFun 日志配置 -func (c *Client) ConfigApiClientFun(apiClientFun golog.ApiClientFun) { - apiClient := apiClientFun() - if apiClient != nil { - c.log.client = apiClient - c.log.status = true - } -} diff --git a/service/gddata/request.go b/service/gddata/request.go index 8d4c5bb9..9db8dfb3 100644 --- a/service/gddata/request.go +++ b/service/gddata/request.go @@ -34,9 +34,6 @@ func (c *Client) request(ctx context.Context, url string, params map[string]inte } // 记录日志 - if c.log.status { - go c.log.client.Middleware(ctx, request) - } return request, err } diff --git a/service/gitee/client.go b/service/gitee/client.go index 7e988342..9d852d57 100644 --- a/service/gitee/client.go +++ b/service/gitee/client.go @@ -1,7 +1,6 @@ package gitee import ( - "github.com/dtapps/go-library/utils/golog" "github.com/dtapps/go-library/utils/gorequest" "gorm.io/gorm" ) @@ -14,9 +13,8 @@ type ConfigClient struct { } type Client struct { - client *gorequest.App // 请求客户端 - log *golog.ApiClient // 日志服务 - config *ConfigClient // 配置 + client *gorequest.App // 请求客户端 + config *ConfigClient // 配置 } func NewClient(config *ConfigClient) (*Client, error) { @@ -26,15 +24,5 @@ func NewClient(config *ConfigClient) (*Client, error) { c.client = gorequest.NewHttp() - if c.config.PgsqlDb != nil { - c.log, err = golog.NewApiClient( - golog.WithGormClient(c.config.PgsqlDb), - golog.WithTableName(logTable), - ) - if err != nil { - return nil, err - } - } - return c, nil } diff --git a/service/gitee/request.go b/service/gitee/request.go index 89a101ae..44aebe0b 100644 --- a/service/gitee/request.go +++ b/service/gitee/request.go @@ -26,9 +26,6 @@ func (c *Client) request(url string, params map[string]interface{}, method strin } // 日志 - if c.config.PgsqlDb != nil { - go c.log.GormMiddleware(request) - } return request, err } diff --git a/service/jd/client.go b/service/jd/client.go index 80049167..fd4beeb5 100644 --- a/service/jd/client.go +++ b/service/jd/client.go @@ -22,10 +22,6 @@ type Client struct { siteId string // 网站ID/APP ID positionId string // 推广位id } - log struct { - status bool // 状态 - client *golog.ApiClient // 日志服务 - } zap struct { status bool // 状态 client *golog.ApiZapLog // 日志服务 diff --git a/service/jd/config.go b/service/jd/config.go index 0d5275d7..fa5deb8a 100644 --- a/service/jd/config.go +++ b/service/jd/config.go @@ -2,15 +2,6 @@ package jd import "github.com/dtapps/go-library/utils/golog" -// ConfigApiClientFun 日志配置 -func (c *Client) ConfigApiClientFun(apiClientFun golog.ApiClientFun) { - apiClient := apiClientFun() - if apiClient != nil { - c.log.client = apiClient - c.log.status = true - } -} - // ConfigZapClientFun 日志配置 func (c *Client) ConfigZapClientFun(apiZapLogFun golog.ApiZapLogFun) { apiZapLog := apiZapLogFun() diff --git a/service/jd/get.go b/service/jd/get.go index aa947fc9..b2125b35 100644 --- a/service/jd/get.go +++ b/service/jd/get.go @@ -1,7 +1,5 @@ package jd -import "github.com/dtapps/go-library/utils/golog" - // GetAppKey 应用Key func (c *Client) GetAppKey() string { return c.config.appKey @@ -21,7 +19,3 @@ func (c *Client) GetSiteId() string { func (c *Client) GetPositionId() string { return c.config.positionId } - -func (c *Client) GetLog() *golog.ApiClient { - return c.log.client -} diff --git a/service/jd/request.go b/service/jd/request.go index e9b3e20f..b7024c05 100644 --- a/service/jd/request.go +++ b/service/jd/request.go @@ -28,9 +28,6 @@ func (c *Client) request(ctx context.Context, params map[string]interface{}) (go } // 记录日志 - if c.log.status { - go c.log.client.MiddlewareCustom(ctx, fmt.Sprintf("%s", params["method"]), request) - } if c.zap.status { go c.zap.client.MiddlewareCustom(ctx, fmt.Sprintf("%s", params["method"]), request) } diff --git a/service/kashangwl/client.go b/service/kashangwl/client.go index 081f0787..550c6740 100644 --- a/service/kashangwl/client.go +++ b/service/kashangwl/client.go @@ -19,14 +19,6 @@ type Client struct { customerId int64 // 商家编号 customerKey string // 商家密钥 } - log struct { - status bool // 状态 - client *golog.ApiClient // 日志服务 - } - cacheLog struct { - status bool // 状态 - client *golog.ApiClient // 日志服务 - } zap struct { status bool // 状态 client *golog.ApiZapLog // 日志服务 @@ -45,7 +37,6 @@ func NewClient(config *ClientConfig) (*Client, error) { c.config.customerId = config.CustomerId c.config.customerKey = config.CustomerKey - c.cacheLog.status = config.CacheLogStatus c.cacheZap.status = config.CacheLogStatus c.requestClient = gorequest.NewHttp() diff --git a/service/kashangwl/config.go b/service/kashangwl/config.go index 693e6bfd..2334ed53 100644 --- a/service/kashangwl/config.go +++ b/service/kashangwl/config.go @@ -2,17 +2,6 @@ package kashangwl import "github.com/dtapps/go-library/utils/golog" -// ConfigApiClientFun 日志配置 -func (c *Client) ConfigApiClientFun(apiClientFun golog.ApiClientFun) { - apiClient := apiClientFun() - if apiClient != nil { - c.log.client = apiClient - c.log.status = true - - c.cacheLog.client = apiClient - } -} - // ConfigZapClientFun 日志配置 func (c *Client) ConfigZapClientFun(apiZapLogFun golog.ApiZapLogFun) { apiZapLog := apiZapLogFun() diff --git a/service/kashangwl/get.go b/service/kashangwl/get.go index 01e10f86..06245d99 100644 --- a/service/kashangwl/get.go +++ b/service/kashangwl/get.go @@ -1,7 +1,5 @@ package kashangwl -import "github.com/dtapps/go-library/utils/golog" - func (c *Client) GetCustomerId() int64 { return c.config.customerId } @@ -9,7 +7,3 @@ func (c *Client) GetCustomerId() int64 { func (c *Client) GetCustomerKey() string { return c.config.customerKey } - -func (c *Client) GetLog() *golog.ApiClient { - return c.log.client -} diff --git a/service/kashangwl/request.go b/service/kashangwl/request.go index fdc3ab90..6b513877 100644 --- a/service/kashangwl/request.go +++ b/service/kashangwl/request.go @@ -37,9 +37,6 @@ func (c *Client) request(ctx context.Context, url string, params map[string]inte } // 日志 - if c.log.status { - go c.log.client.Middleware(ctx, request) - } if c.zap.status { go c.zap.client.Middleware(ctx, request) } @@ -74,11 +71,8 @@ func (c *Client) requestCache(ctx context.Context, url string, params map[string } // 日志 - if c.cacheLog.status { - go c.cacheLog.client.Middleware(ctx, request) - } - if c.cacheLog.status { - go c.cacheLog.client.Middleware(ctx, request) + if c.cacheZap.status { + go c.cacheZap.client.Middleware(ctx, request) } return request, err diff --git a/service/kuaishou/client.go b/service/kuaishou/client.go index a7a5aad9..646c6655 100644 --- a/service/kuaishou/client.go +++ b/service/kuaishou/client.go @@ -15,10 +15,6 @@ type Client struct { config struct { ua string // 用户代理 } - log struct { - status bool // 状态 - client *golog.ApiClient // 日志服务 - } zap struct { status bool // 状态 client *golog.ApiZapLog // 日志服务 diff --git a/service/kuaishou/cofnig.go b/service/kuaishou/cofnig.go index b3020dad..b4772ebf 100644 --- a/service/kuaishou/cofnig.go +++ b/service/kuaishou/cofnig.go @@ -2,15 +2,6 @@ package kuaishou import "github.com/dtapps/go-library/utils/golog" -// ConfigApiClientFun 日志配置 -func (c *Client) ConfigApiClientFun(apiClientFun golog.ApiClientFun) { - apiClient := apiClientFun() - if apiClient != nil { - c.log.client = apiClient - c.log.status = true - } -} - // ConfigZapClientFun 日志配置 func (c *Client) ConfigZapClientFun(apiZapLogFun golog.ApiZapLogFun) { apiZapLog := apiZapLogFun() diff --git a/service/kuaishou/get.go b/service/kuaishou/get.go index 57779ed9..4d3d8f3a 100644 --- a/service/kuaishou/get.go +++ b/service/kuaishou/get.go @@ -1,7 +1 @@ package kuaishou - -import "github.com/dtapps/go-library/utils/golog" - -func (c *Client) GetLog() *golog.ApiClient { - return c.log.client -} diff --git a/service/leshuazf/client.go b/service/leshuazf/client.go index ee24b212..0e18a618 100644 --- a/service/leshuazf/client.go +++ b/service/leshuazf/client.go @@ -19,10 +19,6 @@ type Client struct { environment string // 环境 keyAgent string } - log struct { - status bool // 状态 - client *golog.ApiClient // 日志服务 - } zap struct { status bool // 状态 client *golog.ApiZapLog // 日志服务 diff --git a/service/leshuazf/config.go b/service/leshuazf/config.go index 044c88fc..b81f951f 100644 --- a/service/leshuazf/config.go +++ b/service/leshuazf/config.go @@ -2,15 +2,6 @@ package leshuazf import "github.com/dtapps/go-library/utils/golog" -// ConfigApiClientFun 日志配置 -func (c *Client) ConfigApiClientFun(apiClientFun golog.ApiClientFun) { - apiClient := apiClientFun() - if apiClient != nil { - c.log.client = apiClient - c.log.status = true - } -} - // ConfigZapClientFun 日志配置 func (c *Client) ConfigZapClientFun(apiZapLogFun golog.ApiZapLogFun) { apiZapLog := apiZapLogFun() diff --git a/service/leshuazf/get.go b/service/leshuazf/get.go index b1518605..cdc9d0c9 100644 --- a/service/leshuazf/get.go +++ b/service/leshuazf/get.go @@ -1,13 +1,13 @@ package leshuazf func (c *Client) GetEnvironment() string { - return c.config.Environment + return c.config.environment } func (c *Client) GetAgentId() string { - return c.config.AgentId + return c.config.agentId } func (c *Client) GetKeyAgent() string { - return c.config.KeyAgent + return c.config.keyAgent } diff --git a/service/leshuazf/request.go b/service/leshuazf/request.go index 899b0fdd..f4de8ae3 100644 --- a/service/leshuazf/request.go +++ b/service/leshuazf/request.go @@ -44,9 +44,6 @@ func (c *Client) request(ctx context.Context, url string, params map[string]inte } // 日志 - if c.log.status { - go c.log.client.Middleware(ctx, request) - } if c.zap.status { go c.zap.client.Middleware(ctx, request) } diff --git a/service/meituan/client.go b/service/meituan/client.go index 6d23a186..ff36b55c 100644 --- a/service/meituan/client.go +++ b/service/meituan/client.go @@ -18,10 +18,6 @@ type Client struct { secret string // 秘钥 appKey string // 渠道标记 } - log struct { - status bool // 状态 - client *golog.ApiClient // 日志服务 - } zap struct { status bool // 状态 client *golog.ApiZapLog // 日志服务 diff --git a/service/meituan/config.go b/service/meituan/config.go index 706c0912..144cff54 100644 --- a/service/meituan/config.go +++ b/service/meituan/config.go @@ -2,15 +2,6 @@ package meituan import "github.com/dtapps/go-library/utils/golog" -// ConfigApiClientFun 日志配置 -func (c *Client) ConfigApiClientFun(apiClientFun golog.ApiClientFun) { - apiClient := apiClientFun() - if apiClient != nil { - c.log.client = apiClient - c.log.status = true - } -} - // ConfigZapClientFun 日志配置 func (c *Client) ConfigZapClientFun(apiZapLogFun golog.ApiZapLogFun) { apiZapLog := apiZapLogFun() diff --git a/service/meituan/get.go b/service/meituan/get.go index a56c3293..bf6d7211 100644 --- a/service/meituan/get.go +++ b/service/meituan/get.go @@ -1,7 +1,5 @@ package meituan -import "github.com/dtapps/go-library/utils/golog" - func (c *Client) GetAppKey() string { return c.config.appKey } @@ -9,7 +7,3 @@ func (c *Client) GetAppKey() string { func (c *Client) GetSecret() string { return c.config.secret } - -func (c *Client) GetLog() *golog.ApiClient { - return c.log.client -} diff --git a/service/meituan/request.go b/service/meituan/request.go index fa07748e..e88600e2 100644 --- a/service/meituan/request.go +++ b/service/meituan/request.go @@ -29,9 +29,6 @@ func (c *Client) request(ctx context.Context, url string, params map[string]inte } // 日志 - if c.log.status { - go c.log.client.Middleware(ctx, request) - } if c.zap.status { go c.zap.client.Middleware(ctx, request) } diff --git a/service/nldyp/client.go b/service/nldyp/client.go index e0feb692..779e9c93 100644 --- a/service/nldyp/client.go +++ b/service/nldyp/client.go @@ -16,10 +16,6 @@ type Client struct { config struct { vendor string } - log struct { - status bool // 状态 - client *golog.ApiClient // 日志服务 - } zap struct { status bool // 状态 client *golog.ApiZapLog // 日志服务 diff --git a/service/nldyp/request.go b/service/nldyp/request.go index 9337125f..78d44d2e 100644 --- a/service/nldyp/request.go +++ b/service/nldyp/request.go @@ -29,9 +29,6 @@ func (c *Client) request(ctx context.Context, url string, param map[string]inter } // 日志 - if c.log.status { - go c.log.client.Middleware(ctx, request) - } if c.zap.status { go c.zap.client.Middleware(ctx, request) } diff --git a/service/pconline/client.go b/service/pconline/client.go index 14e2471f..250b66fc 100644 --- a/service/pconline/client.go +++ b/service/pconline/client.go @@ -7,11 +7,7 @@ import ( type Client struct { client *gorequest.App // 请求服务 - log struct { - status bool // 状态 - client *golog.ApiClient // 日志服务 - } - zap struct { + zap struct { status bool // 状态 client *golog.ApiZapLog // 日志服务 } diff --git a/service/pconline/config.go b/service/pconline/config.go index 8987bfe2..a8e8c8d8 100644 --- a/service/pconline/config.go +++ b/service/pconline/config.go @@ -2,15 +2,6 @@ package pconline import "github.com/dtapps/go-library/utils/golog" -// ConfigApiClientFun 日志配置 -func (c *Client) ConfigApiClientFun(apiClientFun golog.ApiClientFun) { - apiClient := apiClientFun() - if apiClient != nil { - c.log.client = apiClient - c.log.status = true - } -} - // ConfigZapClientFun 日志配置 func (c *Client) ConfigZapClientFun(apiZapLogFun golog.ApiZapLogFun) { apiZapLog := apiZapLogFun() diff --git a/service/pconline/request.go b/service/pconline/request.go index 6406c6c1..0af8ccaa 100644 --- a/service/pconline/request.go +++ b/service/pconline/request.go @@ -23,9 +23,6 @@ func (c *Client) request(ctx context.Context, url string, params map[string]inte } // 日志 - if c.log.status { - go c.log.client.Middleware(ctx, request) - } if c.zap.status { go c.zap.client.Middleware(ctx, request) } diff --git a/service/pinduoduo/client.go b/service/pinduoduo/client.go index e89d3591..9a127c7a 100644 --- a/service/pinduoduo/client.go +++ b/service/pinduoduo/client.go @@ -24,10 +24,6 @@ type Client struct { mediaId string // 媒体ID pid string // 推广位 } - log struct { - status bool // 状态 - client *golog.ApiClient // 日志服务 - } zap struct { status bool // 状态 client *golog.ApiZapLog // 日志服务 diff --git a/service/pinduoduo/config.go b/service/pinduoduo/config.go index 2910955b..be093f88 100644 --- a/service/pinduoduo/config.go +++ b/service/pinduoduo/config.go @@ -7,15 +7,6 @@ func (c *Client) ConfigPid(pid string) *Client { return c } -// ConfigApiClientFun 日志配置 -func (c *Client) ConfigApiClientFun(apiClientFun golog.ApiClientFun) { - apiClient := apiClientFun() - if apiClient != nil { - c.log.client = apiClient - c.log.status = true - } -} - // ConfigZapClientFun 日志配置 func (c *Client) ConfigZapClientFun(apiZapLogFun golog.ApiZapLogFun) { apiZapLog := apiZapLogFun() diff --git a/service/pinduoduo/get.go b/service/pinduoduo/get.go index 8991ec30..5f95e23c 100644 --- a/service/pinduoduo/get.go +++ b/service/pinduoduo/get.go @@ -1,7 +1,5 @@ package pinduoduo -import "github.com/dtapps/go-library/utils/golog" - func (c *Client) GetClientId() string { return c.config.clientId } @@ -17,7 +15,3 @@ func (c *Client) GetMediaId() string { func (c *Client) GetPid() string { return c.config.pid } - -func (c *Client) GetLog() *golog.ApiClient { - return c.log.client -} diff --git a/service/pinduoduo/request.go b/service/pinduoduo/request.go index 96699d6f..ee1dcfb8 100644 --- a/service/pinduoduo/request.go +++ b/service/pinduoduo/request.go @@ -24,9 +24,6 @@ func (c *Client) request(ctx context.Context, params map[string]interface{}) (go } // 日志 - if c.log.status { - go c.log.client.MiddlewareCustom(ctx, fmt.Sprintf("%s", params["type"]), request) - } if c.zap.status { go c.zap.client.MiddlewareCustom(ctx, fmt.Sprintf("%s", params["type"]), request) } diff --git a/service/pintoto/client.go b/service/pintoto/client.go index b287f6ab..46d4a249 100644 --- a/service/pintoto/client.go +++ b/service/pintoto/client.go @@ -20,10 +20,6 @@ type Client struct { appKey string appSecret string } - log struct { - status bool // 状态 - client *golog.ApiClient // 日志服务 - } zap struct { status bool // 状态 client *golog.ApiZapLog // 日志服务 diff --git a/service/pintoto/config.go b/service/pintoto/config.go index 4d3c0979..64b1bbeb 100644 --- a/service/pintoto/config.go +++ b/service/pintoto/config.go @@ -2,15 +2,6 @@ package pintoto import "github.com/dtapps/go-library/utils/golog" -// ConfigApiClientFun 日志配置 -func (c *Client) ConfigApiClientFun(apiClientFun golog.ApiClientFun) { - apiClient := apiClientFun() - if apiClient != nil { - c.log.client = apiClient - c.log.status = true - } -} - // ConfigZapClientFun 日志配置 func (c *Client) ConfigZapClientFun(apiZapLogFun golog.ApiZapLogFun) { apiZapLog := apiZapLogFun() diff --git a/service/pintoto/get.go b/service/pintoto/get.go index 03777cd4..326ce392 100644 --- a/service/pintoto/get.go +++ b/service/pintoto/get.go @@ -1,7 +1,5 @@ package pintoto -import "github.com/dtapps/go-library/utils/golog" - func (c *Client) GetAppKey() string { return c.config.appKey } @@ -9,7 +7,3 @@ func (c *Client) GetAppKey() string { func (c *Client) GetAppSecret() string { return c.config.appSecret } - -func (c *Client) GetLog() *golog.ApiClient { - return c.log.client -} diff --git a/service/pintoto/request.go b/service/pintoto/request.go index d5aafbc1..78450b70 100644 --- a/service/pintoto/request.go +++ b/service/pintoto/request.go @@ -35,9 +35,6 @@ func (c *Client) request(ctx context.Context, url string, params map[string]inte } // 记录日志 - if c.log.status { - go c.log.client.Middleware(ctx, request) - } if c.zap.status { go c.zap.client.Middleware(ctx, request) } diff --git a/service/qiniu/client.go b/service/qiniu/client.go index 82162b20..836ad77b 100644 --- a/service/qiniu/client.go +++ b/service/qiniu/client.go @@ -1,7 +1,6 @@ package qiniu import ( - "github.com/dtapps/go-library/utils/golog" "github.com/dtapps/go-library/utils/gorequest" ) @@ -18,10 +17,6 @@ type Client struct { accessKey string secretKey string } - log struct { - status bool // 状态 - client *golog.ApiClient // 日志服务 - } } // NewClient 创建实例化 diff --git a/service/qq/client.go b/service/qq/client.go index ad5fe642..d2384fef 100644 --- a/service/qq/client.go +++ b/service/qq/client.go @@ -16,10 +16,6 @@ type Client struct { config struct { key string } - log struct { - status bool // 状态 - client *golog.ApiClient // 日志服务 - } zap struct { status bool // 状态 client *golog.ApiZapLog // 日志服务 diff --git a/service/qq/config.go b/service/qq/config.go index c781e1be..9508ea96 100644 --- a/service/qq/config.go +++ b/service/qq/config.go @@ -2,15 +2,6 @@ package qq import "github.com/dtapps/go-library/utils/golog" -// ConfigApiClientFun 日志配置 -func (c *Client) ConfigApiClientFun(apiClientFun golog.ApiClientFun) { - apiClient := apiClientFun() - if apiClient != nil { - c.log.client = apiClient - c.log.status = true - } -} - // ConfigZapClientFun 日志配置 func (c *Client) ConfigZapClientFun(apiZapLogFun golog.ApiZapLogFun) { apiZapLog := apiZapLogFun() diff --git a/service/qq/get.go b/service/qq/get.go index e1115f64..74d395b6 100644 --- a/service/qq/get.go +++ b/service/qq/get.go @@ -1,11 +1,5 @@ package qq -import "github.com/dtapps/go-library/utils/golog" - func (c *Client) GetKey() string { return c.config.key } - -func (c *Client) GetLog() *golog.ApiClient { - return c.log.client -} diff --git a/service/qq/request.go b/service/qq/request.go index 0d9527eb..ebbb22bc 100644 --- a/service/qq/request.go +++ b/service/qq/request.go @@ -29,9 +29,6 @@ func (c *Client) request(ctx context.Context, url string, params map[string]inte } // 记录日志 - if c.log.status { - go c.log.client.Middleware(ctx, request) - } if c.zap.status { go c.zap.client.Middleware(ctx, request) } diff --git a/service/sendcloud/client.go b/service/sendcloud/client.go index 2248ba48..46237af5 100644 --- a/service/sendcloud/client.go +++ b/service/sendcloud/client.go @@ -16,10 +16,6 @@ type Client struct { apiUser string // API_USER apiKey string // API_KEY } - log struct { - status bool // 状态 - client *golog.ApiClient // 日志服务 - } zap struct { status bool // 状态 client *golog.ApiZapLog // 日志服务 diff --git a/service/sendcloud/config.go b/service/sendcloud/config.go index 61723047..9c8787d8 100644 --- a/service/sendcloud/config.go +++ b/service/sendcloud/config.go @@ -2,15 +2,6 @@ package sendcloud import "github.com/dtapps/go-library/utils/golog" -// ConfigApiClientFun 日志配置 -func (c *Client) ConfigApiClientFun(apiClientFun golog.ApiClientFun) { - apiClient := apiClientFun() - if apiClient != nil { - c.log.client = apiClient - c.log.status = true - } -} - // ConfigZapClientFun 日志配置 func (c *Client) ConfigZapClientFun(apiZapLogFun golog.ApiZapLogFun) { apiZapLog := apiZapLogFun() diff --git a/service/sendcloud/get.go b/service/sendcloud/get.go index 482773e3..f7a013a4 100644 --- a/service/sendcloud/get.go +++ b/service/sendcloud/get.go @@ -1,9 +1,9 @@ package sendcloud func (c *Client) GetApiUser() string { - return c.config.ApiUser + return c.config.apiUser } func (c *Client) GetApiKey() string { - return c.config.ApiKey + return c.config.apiKey } diff --git a/service/sendcloud/request.go b/service/sendcloud/request.go index 2b6b1260..8c797d0e 100644 --- a/service/sendcloud/request.go +++ b/service/sendcloud/request.go @@ -34,9 +34,6 @@ func (c *Client) request(ctx context.Context, url string, params map[string]inte } // 日志 - if c.log.status { - go c.log.client.Middleware(ctx, request) - } if c.zap.status { go c.zap.client.Middleware(ctx, request) } diff --git a/service/taobao/client.go b/service/taobao/client.go index 8abbe487..8be87a83 100644 --- a/service/taobao/client.go +++ b/service/taobao/client.go @@ -20,10 +20,6 @@ type Client struct { appSecret string // 密钥 adzoneId int64 // mm_xxx_xxx_xxx的第三位 } - log struct { - status bool // 状态 - client *golog.ApiClient // 日志服务 - } zap struct { status bool // 状态 client *golog.ApiZapLog // 日志服务 diff --git a/service/taobao/config.go b/service/taobao/config.go index 339c402c..2702998b 100644 --- a/service/taobao/config.go +++ b/service/taobao/config.go @@ -2,15 +2,6 @@ package taobao import "github.com/dtapps/go-library/utils/golog" -// ConfigApiClientFun 日志配置 -func (c *Client) ConfigApiClientFun(apiClientFun golog.ApiClientFun) { - apiClient := apiClientFun() - if apiClient != nil { - c.log.client = apiClient - c.log.status = true - } -} - // ConfigZapClientFun 日志配置 func (c *Client) ConfigZapClientFun(apiZapLogFun golog.ApiZapLogFun) { apiZapLog := apiZapLogFun() diff --git a/service/taobao/get.go b/service/taobao/get.go index 9a218fcc..6b7723a4 100644 --- a/service/taobao/get.go +++ b/service/taobao/get.go @@ -1,7 +1,5 @@ package taobao -import "github.com/dtapps/go-library/utils/golog" - func (c *Client) GetAppKey() string { return c.config.appKey } @@ -13,7 +11,3 @@ func (c *Client) GetAppSecret() string { func (c *Client) GetAdzoneId() int64 { return c.config.adzoneId } - -func (c *Client) GetLog() *golog.ApiClient { - return c.log.client -} diff --git a/service/taobao/request.go b/service/taobao/request.go index d69c2e94..9e6cc41b 100644 --- a/service/taobao/request.go +++ b/service/taobao/request.go @@ -24,9 +24,6 @@ func (c *Client) request(ctx context.Context, params map[string]interface{}) (go } // 记录日志 - if c.log.status { - go c.log.client.MiddlewareCustom(ctx, fmt.Sprintf("%s", params["method"]), request) - } if c.zap.status { go c.zap.client.MiddlewareCustom(ctx, fmt.Sprintf("%s", params["method"]), request) } diff --git a/service/wechatminiprogram/client.go b/service/wechatminiprogram/client.go index 004295f2..d59c6530 100644 --- a/service/wechatminiprogram/client.go +++ b/service/wechatminiprogram/client.go @@ -30,10 +30,6 @@ type Client struct { redisClient *dorm.RedisClient // 缓存数据库 wechatAccessTokenPrefix string // AccessToken } - log struct { - status bool // 状态 - client *golog.ApiClient // 日志服务 - } zap struct { status bool // 状态 client *golog.ApiZapLog // 日志服务 diff --git a/service/wechatminiprogram/config.go b/service/wechatminiprogram/config.go index 873c6cda..f74fd76b 100644 --- a/service/wechatminiprogram/config.go +++ b/service/wechatminiprogram/config.go @@ -12,15 +12,6 @@ func (c *Client) ConfigApp(appId, appSecret string) *Client { return c } -// ConfigApiClientFun 日志配置 -func (c *Client) ConfigApiClientFun(apiClientFun golog.ApiClientFun) { - apiClient := apiClientFun() - if apiClient != nil { - c.log.client = apiClient - c.log.status = true - } -} - // ConfigRedisClient 缓存数据库 func (c *Client) ConfigRedisClient(client *dorm.RedisClient) { c.cache.redisClient = client diff --git a/service/wechatminiprogram/get.go b/service/wechatminiprogram/get.go index 18ab44bd..1e5c1264 100644 --- a/service/wechatminiprogram/get.go +++ b/service/wechatminiprogram/get.go @@ -2,7 +2,6 @@ package wechatminiprogram import ( "context" - "github.com/dtapps/go-library/utils/golog" ) func (c *Client) GetAppId() string { @@ -20,7 +19,3 @@ func (c *Client) getAccessToken(ctx context.Context) string { c.config.accessToken = c.GetAccessToken(ctx) return c.config.accessToken } - -func (c *Client) GetLog() *golog.ApiClient { - return c.log.client -} diff --git a/service/wechatminiprogram/request.go b/service/wechatminiprogram/request.go index b00d53ce..6067b5fb 100644 --- a/service/wechatminiprogram/request.go +++ b/service/wechatminiprogram/request.go @@ -32,9 +32,6 @@ func (c *Client) request(ctx context.Context, url string, params map[string]inte } // 记录日志 - if c.log.status { - go c.log.client.Middleware(ctx, request) - } if c.zap.status { go c.zap.client.Middleware(ctx, request) } diff --git a/service/wechatoffice/client.go b/service/wechatoffice/client.go index 1802918f..7025f7fd 100644 --- a/service/wechatoffice/client.go +++ b/service/wechatoffice/client.go @@ -33,10 +33,6 @@ type Client struct { wechatAccessTokenPrefix string // AccessToken wechatJsapiTicketPrefix string // JsapiTicket } - log struct { - status bool // 状态 - client *golog.ApiClient // 日志服务 - } zap struct { status bool // 状态 client *golog.ApiZapLog // 日志服务 diff --git a/service/wechatoffice/config.go b/service/wechatoffice/config.go index 9343e77d..992c8085 100644 --- a/service/wechatoffice/config.go +++ b/service/wechatoffice/config.go @@ -9,15 +9,6 @@ func (c *Client) ConfigApp(appId, appSecret string) *Client { return c } -// ConfigApiClientFun 日志配置 -func (c *Client) ConfigApiClientFun(apiClientFun golog.ApiClientFun) { - apiClient := apiClientFun() - if apiClient != nil { - c.log.client = apiClient - c.log.status = true - } -} - // ConfigZapClientFun 日志配置 func (c *Client) ConfigZapClientFun(apiZapLogFun golog.ApiZapLogFun) { apiZapLog := apiZapLogFun() diff --git a/service/wechatoffice/get.go b/service/wechatoffice/get.go index 5e6907c4..16456e8b 100644 --- a/service/wechatoffice/get.go +++ b/service/wechatoffice/get.go @@ -2,7 +2,6 @@ package wechatoffice import ( "context" - "github.com/dtapps/go-library/utils/golog" ) func (c *Client) GetAppId() string { @@ -22,7 +21,3 @@ func (c *Client) getJsapiTicket(ctx context.Context) string { c.config.jsapiTicket = c.GetJsapiTicket(ctx) return c.config.jsapiTicket } - -func (c *Client) GetLog() *golog.ApiClient { - return c.log.client -} diff --git a/service/wechatoffice/request.go b/service/wechatoffice/request.go index 5aaf5bbd..cbbd58e3 100644 --- a/service/wechatoffice/request.go +++ b/service/wechatoffice/request.go @@ -32,9 +32,6 @@ func (c *Client) request(ctx context.Context, url string, params map[string]inte } // 记录日志 - if c.log.status { - go c.log.client.Middleware(ctx, request) - } if c.zap.status { go c.zap.client.Middleware(ctx, request) } diff --git a/service/wechatopen/client.go b/service/wechatopen/client.go index 62d9bad3..cd27fa64 100644 --- a/service/wechatopen/client.go +++ b/service/wechatopen/client.go @@ -46,10 +46,6 @@ type Client struct { authorizerAccessTokenPrefix string preAuthCodePrefix string } - log struct { - status bool // 状态 - client *golog.ApiClient // 日志服务 - } zap struct { status bool // 状态 client *golog.ApiZapLog // 日志服务 diff --git a/service/wechatopen/config.go b/service/wechatopen/config.go index 11520054..b70dc80a 100644 --- a/service/wechatopen/config.go +++ b/service/wechatopen/config.go @@ -15,15 +15,6 @@ func (c *Client) ConfigAuthorizer(authorizerAppid string) *Client { return c } -// ConfigApiClientFun 日志配置 -func (c *Client) ConfigApiClientFun(apiClientFun golog.ApiClientFun) { - apiClient := apiClientFun() - if apiClient != nil { - c.log.client = apiClient - c.log.status = true - } -} - // ConfigZapClientFun 日志配置 func (c *Client) ConfigZapClientFun(apiZapLogFun golog.ApiZapLogFun) { apiZapLog := apiZapLogFun() diff --git a/service/wechatopen/get.go b/service/wechatopen/get.go index dd50c768..3b3e6771 100644 --- a/service/wechatopen/get.go +++ b/service/wechatopen/get.go @@ -2,7 +2,6 @@ package wechatopen import ( "context" - "github.com/dtapps/go-library/utils/golog" ) // GetComponentAppId 第三方平台appid @@ -29,7 +28,3 @@ func (c *Client) GetMessageKey(ctx context.Context) string { func (c *Client) GetAuthorizerAppid(ctx context.Context) string { return c.config.authorizerAppid } - -func (c *Client) GetLog(ctx context.Context) *golog.ApiClient { - return c.log.client -} diff --git a/service/wechatopen/request.go b/service/wechatopen/request.go index 9234293f..30506fcd 100644 --- a/service/wechatopen/request.go +++ b/service/wechatopen/request.go @@ -35,9 +35,6 @@ func (c *Client) request(ctx context.Context, url string, params map[string]inte } // 记录日志 - if c.log.status { - go c.log.client.Middleware(ctx, request) - } if c.zap.status { go c.zap.client.Middleware(ctx, request) } diff --git a/service/wechatpayapiv2/client.go b/service/wechatpayapiv2/client.go index f7a3abb4..4f8ab733 100644 --- a/service/wechatpayapiv2/client.go +++ b/service/wechatpayapiv2/client.go @@ -26,10 +26,6 @@ type Client struct { certString string keyString string } - log struct { - status bool // 状态 - client *golog.ApiClient // 日志服务 - } zap struct { status bool // 状态 client *golog.ApiZapLog // 日志服务 diff --git a/service/wechatpayapiv2/config.go b/service/wechatpayapiv2/config.go index fb0f36ef..0f935a8a 100644 --- a/service/wechatpayapiv2/config.go +++ b/service/wechatpayapiv2/config.go @@ -2,15 +2,6 @@ package wechatpayapiv2 import "github.com/dtapps/go-library/utils/golog" -// ConfigApiClientFun 日志配置 -func (c *Client) ConfigApiClientFun(apiClientFun golog.ApiClientFun) { - apiClient := apiClientFun() - if apiClient != nil { - c.log.client = apiClient - c.log.status = true - } -} - // ConfigZapClientFun 日志配置 func (c *Client) ConfigZapClientFun(apiZapLogFun golog.ApiZapLogFun) { apiZapLog := apiZapLogFun() diff --git a/service/wechatpayapiv2/get.go b/service/wechatpayapiv2/get.go index 37035b42..fcda7367 100644 --- a/service/wechatpayapiv2/get.go +++ b/service/wechatpayapiv2/get.go @@ -2,7 +2,6 @@ package wechatpayapiv2 import ( "crypto/tls" - "github.com/dtapps/go-library/utils/golog" ) func (c *Client) GetAppId() string { @@ -33,7 +32,3 @@ func (c *Client) P12ToPem() (*tls.Certificate, error) { pemCert, err := tls.X509KeyPair([]byte(c.GetCertString()), []byte(c.GetKeyString())) return &pemCert, err } - -func (c *Client) GetLog() *golog.ApiClient { - return c.log.client -} diff --git a/service/wechatpayapiv2/request.go b/service/wechatpayapiv2/request.go index f156c4f9..ea3a093c 100644 --- a/service/wechatpayapiv2/request.go +++ b/service/wechatpayapiv2/request.go @@ -35,9 +35,6 @@ func (c *Client) request(ctx context.Context, url string, params map[string]inte } // 记录日志 - if c.log.status { - go c.log.client.MiddlewareXml(ctx, request) - } if c.zap.status { go c.zap.client.MiddlewareXml(ctx, request) } diff --git a/service/wechatpayapiv3/client.go b/service/wechatpayapiv3/client.go index 05bb7e0e..9f8defb2 100644 --- a/service/wechatpayapiv3/client.go +++ b/service/wechatpayapiv3/client.go @@ -28,10 +28,6 @@ type Client struct { mchSslSerialNo string // pem 证书号 mchSslKey string // pem key 内容 } - log struct { - status bool // 状态 - client *golog.ApiClient // 日志服务 - } zap struct { status bool // 状态 client *golog.ApiZapLog // 日志服务 diff --git a/service/wechatpayapiv3/config.go b/service/wechatpayapiv3/config.go index cdff43aa..2c01d5b1 100644 --- a/service/wechatpayapiv3/config.go +++ b/service/wechatpayapiv3/config.go @@ -8,15 +8,6 @@ func (c *Client) ConfigApp(appId, appSecret string) *Client { return c } -// ConfigApiClientFun 日志配置 -func (c *Client) ConfigApiClientFun(apiClientFun golog.ApiClientFun) { - apiClient := apiClientFun() - if apiClient != nil { - c.log.client = apiClient - c.log.status = true - } -} - // ConfigZapClientFun 日志配置 func (c *Client) ConfigZapClientFun(apiZapLogFun golog.ApiZapLogFun) { apiZapLog := apiZapLogFun() diff --git a/service/wechatpayapiv3/get.go b/service/wechatpayapiv3/get.go index e49e33f8..c84c62cc 100644 --- a/service/wechatpayapiv3/get.go +++ b/service/wechatpayapiv3/get.go @@ -1,7 +1,5 @@ package wechatpayapiv3 -import "github.com/dtapps/go-library/utils/golog" - func (c *Client) GetAppId() string { return c.config.appId } @@ -29,7 +27,3 @@ func (c *Client) GetMchSslKey() string { func (c *Client) GetMchSslSerialNo() string { return c.config.mchSslSerialNo } - -func (c *Client) GetLog() *golog.ApiClient { - return c.log.client -} diff --git a/service/wechatpayapiv3/request.go b/service/wechatpayapiv3/request.go index 2763c12c..72dba35b 100644 --- a/service/wechatpayapiv3/request.go +++ b/service/wechatpayapiv3/request.go @@ -55,9 +55,6 @@ func (c *Client) request(ctx context.Context, url string, params map[string]inte } // 记录日志 - if c.log.status { - go c.log.client.Middleware(ctx, request) - } if c.zap.status { go c.zap.client.Middleware(ctx, request) } diff --git a/service/wechatpayopen/client.go b/service/wechatpayopen/client.go index c65d5890..4430d4c7 100644 --- a/service/wechatpayopen/client.go +++ b/service/wechatpayopen/client.go @@ -32,10 +32,6 @@ type Client struct { mchSslCer string // pem 内容 mchSslKey string // pem key 内容 } - log struct { - status bool // 状态 - client *golog.ApiClient // 日志服务 - } zap struct { status bool // 状态 client *golog.ApiZapLog // 日志服务 diff --git a/service/wechatpayopen/config.go b/service/wechatpayopen/config.go index b3e58789..54cda62a 100644 --- a/service/wechatpayopen/config.go +++ b/service/wechatpayopen/config.go @@ -4,15 +4,6 @@ import ( "github.com/dtapps/go-library/utils/golog" ) -// ConfigApiClientFun 日志配置 -func (c *Client) ConfigApiClientFun(apiClientFun golog.ApiClientFun) { - apiClient := apiClientFun() - if apiClient != nil { - c.log.client = apiClient - c.log.status = true - } -} - // ConfigZapClientFun 日志配置 func (c *Client) ConfigZapClientFun(apiZapLogFun golog.ApiZapLogFun) { apiZapLog := apiZapLogFun() diff --git a/service/wechatpayopen/get.go b/service/wechatpayopen/get.go index e980808b..6c1d0460 100644 --- a/service/wechatpayopen/get.go +++ b/service/wechatpayopen/get.go @@ -1,7 +1,5 @@ package wechatpayopen -import "github.com/dtapps/go-library/utils/golog" - func (c *Client) GetSpAppid() string { return c.config.spAppid } @@ -29,7 +27,3 @@ func (c *Client) GetMchSslSerialNo() string { func (c *Client) GetApiV3() string { return c.config.apiV3 } - -func (c *Client) GetLog() *golog.ApiClient { - return c.log.client -} diff --git a/service/wechatpayopen/request.go b/service/wechatpayopen/request.go index 4a85c9be..2072c291 100644 --- a/service/wechatpayopen/request.go +++ b/service/wechatpayopen/request.go @@ -48,9 +48,6 @@ func (c *Client) request(ctx context.Context, url string, params map[string]inte } // 记录日志 - if c.log.status { - go c.log.client.Middleware(ctx, request) - } if c.zap.status { go c.zap.client.Middleware(ctx, request) } diff --git a/service/wechatqy/client.go b/service/wechatqy/client.go index 14274cba..826f3dc1 100644 --- a/service/wechatqy/client.go +++ b/service/wechatqy/client.go @@ -24,10 +24,6 @@ type Client struct { redirectUri string key string } - log struct { - status bool // 状态 - client *golog.ApiClient // 日志服务 - } zap struct { status bool // 状态 client *golog.ApiZapLog // 日志服务 diff --git a/service/wechatqy/config.go b/service/wechatqy/config.go index 1d95265d..1c165116 100644 --- a/service/wechatqy/config.go +++ b/service/wechatqy/config.go @@ -7,15 +7,6 @@ func (c *Client) Config(key string) *Client { return c } -// ConfigApiClientFun 日志配置 -func (c *Client) ConfigApiClientFun(apiClientFun golog.ApiClientFun) { - apiClient := apiClientFun() - if apiClient != nil { - c.log.client = apiClient - c.log.status = true - } -} - // ConfigZapClientFun 日志配置 func (c *Client) ConfigZapClientFun(apiZapLogFun golog.ApiZapLogFun) { apiZapLog := apiZapLogFun() diff --git a/service/wechatqy/get.go b/service/wechatqy/get.go index 54b23982..ab6b948c 100644 --- a/service/wechatqy/get.go +++ b/service/wechatqy/get.go @@ -1,7 +1,5 @@ package wechatqy -import "github.com/dtapps/go-library/utils/golog" - func (c *Client) GetKey() string { return c.config.key } @@ -21,7 +19,3 @@ func (c *Client) GetSecret() string { func (c *Client) GetRedirectUri() string { return c.config.redirectUri } - -func (c *Client) GetLog() *golog.ApiClient { - return c.log.client -} diff --git a/service/wechatqy/request.go b/service/wechatqy/request.go index bd517101..8a72a5f9 100644 --- a/service/wechatqy/request.go +++ b/service/wechatqy/request.go @@ -28,9 +28,6 @@ func (c *Client) request(ctx context.Context, url string, params map[string]inte } // 记录日志 - if c.log.status { - go c.log.client.Middleware(ctx, request) - } if c.zap.status { go c.zap.client.Middleware(ctx, request) } diff --git a/service/wechatunion/client.go b/service/wechatunion/client.go index 5c213c5d..312960e4 100644 --- a/service/wechatunion/client.go +++ b/service/wechatunion/client.go @@ -32,10 +32,6 @@ type Client struct { redisClient *dorm.RedisClient // 缓存数据库 wechatAccessTokenPrefix string // AccessToken } - log struct { - status bool // 状态 - client *golog.ApiClient // 日志服务 - } zap struct { status bool // 状态 client *golog.ApiZapLog // 日志服务 diff --git a/service/wechatunion/config.go b/service/wechatunion/config.go index 71c8a5da..f24d5e1d 100644 --- a/service/wechatunion/config.go +++ b/service/wechatunion/config.go @@ -15,15 +15,6 @@ func (c *Client) ConfigPid(pid string) *Client { return c } -// ConfigApiClientFun 日志配置 -func (c *Client) ConfigApiClientFun(apiClientFun golog.ApiClientFun) { - apiClient := apiClientFun() - if apiClient != nil { - c.log.client = apiClient - c.log.status = true - } -} - // ConfigZapClientFun 日志配置 func (c *Client) ConfigZapClientFun(apiZapLogFun golog.ApiZapLogFun) { apiZapLog := apiZapLogFun() diff --git a/service/wechatunion/get.go b/service/wechatunion/get.go index 4c7e802a..cbcd9453 100644 --- a/service/wechatunion/get.go +++ b/service/wechatunion/get.go @@ -2,7 +2,6 @@ package wechatunion import ( "context" - "github.com/dtapps/go-library/utils/golog" ) func (c *Client) GetAppId() string { @@ -21,7 +20,3 @@ func (c *Client) getAccessToken(ctx context.Context) string { c.config.accessToken = c.GetAccessToken(ctx) return c.config.accessToken } - -func (c *Client) GetLog() *golog.ApiClient { - return c.log.client -} diff --git a/service/wechatunion/request.go b/service/wechatunion/request.go index c68f5aa5..ae5b6f80 100644 --- a/service/wechatunion/request.go +++ b/service/wechatunion/request.go @@ -32,9 +32,6 @@ func (c *Client) request(ctx context.Context, url string, params map[string]inte } // 记录日志 - if c.log.status { - go c.log.client.Middleware(ctx, request) - } if c.zap.status { go c.zap.client.Middleware(ctx, request) } diff --git a/service/weishi/client.go b/service/weishi/client.go index a03cb1a7..c2acb9eb 100644 --- a/service/weishi/client.go +++ b/service/weishi/client.go @@ -18,10 +18,6 @@ type Client struct { config struct { ua string // 用户代理 } - log struct { - status bool // 状态 - client *golog.ApiClient // 日志服务 - } zap struct { status bool // 状态 client *golog.ApiZapLog // 日志服务 diff --git a/service/weishi/config.go b/service/weishi/config.go index a8f58a76..7cd443a4 100644 --- a/service/weishi/config.go +++ b/service/weishi/config.go @@ -2,15 +2,6 @@ package weishi import "github.com/dtapps/go-library/utils/golog" -// ConfigApiClientFun 日志配置 -func (c *Client) ConfigApiClientFun(apiClientFun golog.ApiClientFun) { - apiClient := apiClientFun() - if apiClient != nil { - c.log.client = apiClient - c.log.status = true - } -} - // ConfigZapClientFun 日志配置 func (c *Client) ConfigZapClientFun(apiZapLogFun golog.ApiZapLogFun) { apiZapLog := apiZapLogFun() diff --git a/service/weishi/get.go b/service/weishi/get.go index d546fa04..0479c989 100644 --- a/service/weishi/get.go +++ b/service/weishi/get.go @@ -1,7 +1 @@ package weishi - -import "github.com/dtapps/go-library/utils/golog" - -func (c *Client) GetLog() *golog.ApiClient { - return c.log.client -} diff --git a/service/weishi/request.go b/service/weishi/request.go index 5322e88d..91c1e02d 100644 --- a/service/weishi/request.go +++ b/service/weishi/request.go @@ -23,9 +23,6 @@ func (c *Client) request(ctx context.Context, url string) (gorequest.Response, e } // 记录日志 - if c.log.status { - go c.log.client.Middleware(ctx, request) - } if c.zap.status { go c.zap.client.Middleware(ctx, request) } diff --git a/service/wikeyun/client.go b/service/wikeyun/client.go index 17f1cfad..33adff8b 100644 --- a/service/wikeyun/client.go +++ b/service/wikeyun/client.go @@ -22,10 +22,6 @@ type Client struct { appKey int64 // key appSecret string // secret } - log struct { - status bool // 状态 - client *golog.ApiClient // 日志服务 - } zap struct { status bool // 状态 client *golog.ApiZapLog // 日志服务 diff --git a/service/wikeyun/config.go b/service/wikeyun/config.go index 7ff0402d..1ef1ee67 100644 --- a/service/wikeyun/config.go +++ b/service/wikeyun/config.go @@ -10,15 +10,6 @@ func (c *Client) ConfigApp(storeId, appKey int64, appSecret string) *Client { return c } -// ConfigApiClientFun 日志配置 -func (c *Client) ConfigApiClientFun(apiClientFun golog.ApiClientFun) { - apiClient := apiClientFun() - if apiClient != nil { - c.log.client = apiClient - c.log.status = true - } -} - // ConfigZapClientFun 日志配置 func (c *Client) ConfigZapClientFun(apiZapLogFun golog.ApiZapLogFun) { apiZapLog := apiZapLogFun() diff --git a/service/wikeyun/get.go b/service/wikeyun/get.go index 8ac15690..486e9d04 100644 --- a/service/wikeyun/get.go +++ b/service/wikeyun/get.go @@ -1,7 +1,5 @@ package wikeyun -import "github.com/dtapps/go-library/utils/golog" - func (c *Client) GetStoreId() int64 { return c.config.storeId } @@ -17,7 +15,3 @@ func (c *Client) GetAppSecret() string { func (c *Client) GetClientIp() string { return c.config.clientIp } - -func (c *Client) GetLog() *golog.ApiClient { - return c.log.client -} diff --git a/service/wikeyun/request.go b/service/wikeyun/request.go index 5b8b6828..d6c32db4 100644 --- a/service/wikeyun/request.go +++ b/service/wikeyun/request.go @@ -31,9 +31,6 @@ func (c *Client) request(ctx context.Context, url string, params map[string]inte } // 日志 - if c.log.status { - go c.log.client.Middleware(ctx, request) - } if c.zap.status { go c.zap.client.Middleware(ctx, request) } diff --git a/service/wnfuwu/client.go b/service/wnfuwu/client.go index b90bbaf5..545fbfcd 100644 --- a/service/wnfuwu/client.go +++ b/service/wnfuwu/client.go @@ -18,10 +18,6 @@ type Client struct { userId int64 // 商户ID apiKey string // 秘钥 } - log struct { - status bool // 状态 - client *golog.ApiClient // 日志服务 - } zap struct { status bool // 状态 client *golog.ApiZapLog // 日志服务 diff --git a/service/wnfuwu/config.go b/service/wnfuwu/config.go index 9a1a833a..53948672 100644 --- a/service/wnfuwu/config.go +++ b/service/wnfuwu/config.go @@ -9,15 +9,6 @@ func (c *Client) ConfigApp(userId int64, apiKey string) *Client { return c } -// ConfigApiClientFun 日志配置 -func (c *Client) ConfigApiClientFun(apiClientFun golog.ApiClientFun) { - apiClient := apiClientFun() - if apiClient != nil { - c.log.client = apiClient - c.log.status = true - } -} - // ConfigZapClientFun 日志配置 func (c *Client) ConfigZapClientFun(apiZapLogFun golog.ApiZapLogFun) { apiZapLog := apiZapLogFun() diff --git a/service/wnfuwu/get.go b/service/wnfuwu/get.go index b32ad55c..1ed8ccff 100644 --- a/service/wnfuwu/get.go +++ b/service/wnfuwu/get.go @@ -1,7 +1,5 @@ package wnfuwu -import "github.com/dtapps/go-library/utils/golog" - func (c *Client) GetUserId() int64 { return c.config.userId } @@ -9,7 +7,3 @@ func (c *Client) GetUserId() int64 { func (c *Client) GetApiKey() string { return c.config.apiKey } - -func (c *Client) GetLog() *golog.ApiClient { - return c.log.client -} diff --git a/service/wnfuwu/request.go b/service/wnfuwu/request.go index 26e8859b..29017291 100644 --- a/service/wnfuwu/request.go +++ b/service/wnfuwu/request.go @@ -30,9 +30,6 @@ func (c *Client) request(ctx context.Context, url string, params map[string]inte } // 日志 - if c.log.status { - go c.log.client.Middleware(ctx, request) - } if c.zap.status { go c.zap.client.Middleware(ctx, request) } diff --git a/utils/golog/api.go b/utils/golog/api.go deleted file mode 100644 index f454f432..00000000 --- a/utils/golog/api.go +++ /dev/null @@ -1,112 +0,0 @@ -package golog - -import ( - "context" - "errors" - "github.com/dtapps/go-library/utils/dorm" - "github.com/dtapps/go-library/utils/goip" - "github.com/dtapps/go-library/utils/gorequest" -) - -// ApiClientFun *ApiClient 驱动 -type ApiClientFun func() *ApiClient - -// ApiClient 接口 -type ApiClient struct { - gormClient *dorm.GormClient // 数据库驱动 - zapLog *ZapLog // 日志服务 - config struct { - systemHostname string // 主机名 - systemOs string // 系统类型 - systemVersion string // 系统版本 - systemKernel string // 系统内核 - systemKernelVersion string // 系统内核版本 - systemBootTime uint64 // 系统开机时间 - cpuCores int // CPU核数 - cpuModelName string // CPU型号名称 - cpuMhz float64 // CPU兆赫 - systemInsideIp string // 内网ip - systemOutsideIp string // 外网ip - goVersion string // go版本 - sdkVersion string // sdk版本 - } - gormConfig struct { - stats bool // 状态 - tableName string // 表名 - } -} - -// ApiClientConfig 接口实例配置 -type ApiClientConfig struct { - GormClientFun dorm.GormClientTableFun // 日志配置 - MongoClientFun dorm.MongoClientCollectionFun // 日志配置 - ZapLog *ZapLog // 日志服务 - CurrentIp string // 当前ip -} - -// NewApiClient 创建接口实例化 -func NewApiClient(config *ApiClientConfig) (*ApiClient, error) { - - var ctx = context.Background() - - c := &ApiClient{} - - c.zapLog = config.ZapLog - - if config.CurrentIp != "" && config.CurrentIp != "0.0.0.0" { - c.config.systemOutsideIp = config.CurrentIp - } - c.config.systemOutsideIp = goip.IsIp(c.config.systemOutsideIp) - if c.config.systemOutsideIp == "" { - return nil, currentIpNoConfig - } - - // 配置信息 - c.setConfig(ctx) - - gormClient, gormTableName := config.GormClientFun() - - if gormClient == nil || gormClient.GetDb() == nil { - return nil, dbClientFunNoConfig - } - - // 配置关系数据库 - if gormClient != nil || gormClient.GetDb() != nil { - - c.gormClient = gormClient - - if gormTableName == "" { - return nil, errors.New("没有设置表名") - } else { - c.gormConfig.tableName = gormTableName - } - - // 创建模型 - c.gormAutoMigrate(ctx) - - c.gormConfig.stats = true - } - - return c, nil -} - -// Middleware 中间件 -func (c *ApiClient) Middleware(ctx context.Context, request gorequest.Response) { - if c.gormConfig.stats { - c.gormMiddleware(ctx, request) - } -} - -// MiddlewareXml 中间件 -func (c *ApiClient) MiddlewareXml(ctx context.Context, request gorequest.Response) { - if c.gormConfig.stats { - c.gormMiddlewareXml(ctx, request) - } -} - -// MiddlewareCustom 中间件 -func (c *ApiClient) MiddlewareCustom(ctx context.Context, api string, request gorequest.Response) { - if c.gormConfig.stats { - c.gormMiddlewareCustom(ctx, api, request) - } -} diff --git a/utils/golog/api_cofing.go b/utils/golog/api_cofing.go deleted file mode 100644 index 6cfc3c01..00000000 --- a/utils/golog/api_cofing.go +++ /dev/null @@ -1,28 +0,0 @@ -package golog - -import ( - "context" - "github.com/dtapps/go-library" - "github.com/dtapps/go-library/utils/goip" - "runtime" -) - -func (c *ApiClient) setConfig(ctx context.Context) { - - info := getSystem() - - c.config.systemHostname = info.SystemHostname - c.config.systemOs = info.SystemOs - c.config.systemVersion = info.SystemVersion - c.config.systemKernel = info.SystemKernel - c.config.systemKernelVersion = info.SystemKernelVersion - c.config.systemBootTime = info.SystemBootTime - c.config.cpuCores = info.CpuCores - c.config.cpuModelName = info.CpuModelName - c.config.cpuMhz = info.CpuMhz - - c.config.systemInsideIp = goip.GetInsideIp(ctx) - - c.config.sdkVersion = go_library.Version() - c.config.goVersion = runtime.Version() -} diff --git a/utils/golog/api_gorm.go b/utils/golog/api_gorm.go deleted file mode 100644 index 797e0456..00000000 --- a/utils/golog/api_gorm.go +++ /dev/null @@ -1,157 +0,0 @@ -package golog - -import ( - "context" - "github.com/dtapps/go-library" - "github.com/dtapps/go-library/utils/dorm" - "github.com/dtapps/go-library/utils/gorequest" - "github.com/dtapps/go-library/utils/gotime" - "github.com/dtapps/go-library/utils/gotrace_id" - "github.com/dtapps/go-library/utils/gourl" - "time" - "unicode/utf8" -) - -// 模型 -type apiPostgresqlLog struct { - LogId uint `gorm:"primaryKey;comment:【记录】编号" json:"log_id,omitempty"` //【记录】编号 - TraceId string `gorm:"index;comment:【系统】跟踪编号" json:"trace_id,omitempty"` //【系统】跟踪编号 - RequestTime time.Time `gorm:"index;comment:【请求】时间" json:"request_time,omitempty"` //【请求】时间 - RequestUri string `gorm:"comment:【请求】链接" json:"request_uri,omitempty"` //【请求】链接 - RequestUrl string `gorm:"comment:【请求】链接" json:"request_url,omitempty"` //【请求】链接 - RequestApi string `gorm:"index;comment:【请求】接口" json:"request_api,omitempty"` //【请求】接口 - RequestMethod string `gorm:"index;comment:【请求】方式" json:"request_method,omitempty"` //【请求】方式 - RequestParams string `gorm:"comment:【请求】参数" json:"request_params,omitempty"` //【请求】参数 - RequestHeader string `gorm:"comment:【请求】头部" json:"request_header,omitempty"` //【请求】头部 - RequestIp string `gorm:"default:0.0.0.0;index;comment:【请求】请求Ip" json:"request_ip,omitempty"` //【请求】请求Ip - ResponseHeader string `gorm:"comment:【返回】头部" json:"response_header,omitempty"` //【返回】头部 - ResponseStatusCode int `gorm:"index;comment:【返回】状态码" json:"response_status_code,omitempty"` //【返回】状态码 - ResponseBody string `gorm:"comment:【返回】数据" json:"response_body,omitempty"` //【返回】数据 - ResponseContentLength int64 `gorm:"comment:【返回】大小" json:"response_content_length,omitempty"` //【返回】大小 - ResponseTime time.Time `gorm:"index;comment:【返回】时间" json:"response_time,omitempty"` //【返回】时间 - SystemHostName string `gorm:"index;comment:【系统】主机名" json:"system_host_name,omitempty"` //【系统】主机名 - SystemInsideIp string `gorm:"default:0.0.0.0;comment:【系统】内网ip" json:"system_inside_ip,omitempty"` //【系统】内网ip - SystemOs string `gorm:"index;comment:【系统】系统类型" json:"system_os,omitempty"` //【系统】系统类型 - SystemArch string `gorm:"index;comment:【系统】系统架构" json:"system_arch,omitempty"` //【系统】系统架构 - GoVersion string `gorm:"comment:【程序】Go版本" json:"go_version,omitempty"` //【程序】Go版本 - SdkVersion string `gorm:"comment:【程序】Sdk版本" json:"sdk_version,omitempty"` //【程序】Sdk版本 -} - -// 创建模型 -func (c *ApiClient) gormAutoMigrate(ctx context.Context) { - err := c.gormClient.GetDb().Table(c.gormConfig.tableName).AutoMigrate(&apiPostgresqlLog{}) - if err != nil { - c.zapLog.WithTraceId(ctx).Sugar().Errorf("创建模型:%s", err) - } -} - -// 记录日志 -func (c *ApiClient) gormRecord(ctx context.Context, data apiPostgresqlLog) { - - if utf8.ValidString(data.ResponseBody) == false { - data.ResponseBody = "" - } - - data.SystemHostName = c.config.systemHostname //【系统】主机名 - data.SystemInsideIp = c.config.systemInsideIp //【系统】内网ip - data.GoVersion = c.config.goVersion //【程序】Go版本 - data.TraceId = gotrace_id.GetTraceIdContext(ctx) //【记录】跟踪编号 - data.RequestIp = c.config.systemOutsideIp //【请求】请求Ip - data.SystemOs = c.config.systemOs //【系统】系统类型 - data.SystemArch = c.config.systemKernel //【系统】系统架构 - - err := c.gormClient.GetDb().Table(c.gormConfig.tableName).Create(&data).Error - if err != nil { - c.zapLog.WithTraceId(ctx).Sugar().Errorf("记录接口日志错误:%s", err) - c.zapLog.WithTraceId(ctx).Sugar().Errorf("记录接口日志数据:%+v", data) - } -} - -// GormDelete 删除 -func (c *ApiClient) GormDelete(ctx context.Context, hour int64) error { - return c.GormCustomTableDelete(ctx, c.gormConfig.tableName, hour) -} - -// GormCustomTableDelete 删除数据 - 自定义表名 -func (c *ApiClient) GormCustomTableDelete(ctx context.Context, tableName string, hour int64) error { - err := c.gormClient.GetDb().Table(tableName).Where("request_time < ?", gotime.Current().BeforeHour(hour).Format()).Delete(&apiPostgresqlLog{}).Error - if err != nil { - c.zapLog.WithTraceId(ctx).Sugar().Errorf("删除失败:%s", err) - } - return err -} - -// 中间件 -func (c *ApiClient) gormMiddleware(ctx context.Context, request gorequest.Response) { - data := apiPostgresqlLog{ - RequestTime: request.RequestTime, //【请求】时间 - RequestUri: request.RequestUri, //【请求】链接 - RequestUrl: gourl.UriParse(request.RequestUri).Url, //【请求】链接 - RequestApi: gourl.UriParse(request.RequestUri).Path, //【请求】接口 - RequestMethod: request.RequestMethod, //【请求】方式 - RequestParams: dorm.JsonEncodeNoError(request.RequestParams), //【请求】参数 - RequestHeader: dorm.JsonEncodeNoError(request.RequestHeader), //【请求】头部 - ResponseHeader: dorm.JsonEncodeNoError(request.ResponseHeader), //【返回】头部 - ResponseStatusCode: request.ResponseStatusCode, //【返回】状态码 - ResponseContentLength: request.ResponseContentLength, //【返回】大小 - ResponseTime: request.ResponseTime, //【返回】时间 - SdkVersion: go_library.Version(), //【程序】Sdk版本 - } - if !request.HeaderIsImg() { - if len(request.ResponseBody) > 0 { - data.ResponseBody = dorm.JsonEncodeNoError(dorm.JsonDecodeNoError(request.ResponseBody)) //【返回】数据 - } - } - - c.gormRecord(ctx, data) -} - -// 中间件 -func (c *ApiClient) gormMiddlewareXml(ctx context.Context, request gorequest.Response) { - data := apiPostgresqlLog{ - RequestTime: request.RequestTime, //【请求】时间 - RequestUri: request.RequestUri, //【请求】链接 - RequestUrl: gourl.UriParse(request.RequestUri).Url, //【请求】链接 - RequestApi: gourl.UriParse(request.RequestUri).Path, //【请求】接口 - RequestMethod: request.RequestMethod, //【请求】方式 - RequestParams: dorm.JsonEncodeNoError(request.RequestParams), //【请求】参数 - RequestHeader: dorm.JsonEncodeNoError(request.RequestHeader), //【请求】头部 - ResponseHeader: dorm.JsonEncodeNoError(request.ResponseHeader), //【返回】头部 - ResponseStatusCode: request.ResponseStatusCode, //【返回】状态码 - ResponseContentLength: request.ResponseContentLength, //【返回】大小 - ResponseTime: request.ResponseTime, //【返回】时间 - SdkVersion: go_library.Version(), //【程序】Sdk版本 - } - if !request.HeaderIsImg() { - if len(request.ResponseBody) > 0 { - data.ResponseBody = dorm.XmlEncodeNoError(dorm.XmlDecodeNoError(request.ResponseBody)) //【返回】内容 - } - } - - c.gormRecord(ctx, data) -} - -// 中间件 -func (c *ApiClient) gormMiddlewareCustom(ctx context.Context, api string, request gorequest.Response) { - data := apiPostgresqlLog{ - RequestTime: request.RequestTime, //【请求】时间 - RequestUri: request.RequestUri, //【请求】链接 - RequestUrl: gourl.UriParse(request.RequestUri).Url, //【请求】链接 - RequestApi: api, //【请求】接口 - RequestMethod: request.RequestMethod, //【请求】方式 - RequestParams: dorm.JsonEncodeNoError(request.RequestParams), //【请求】参数 - RequestHeader: dorm.JsonEncodeNoError(request.RequestHeader), //【请求】头部 - ResponseHeader: dorm.JsonEncodeNoError(request.ResponseHeader), //【返回】头部 - ResponseStatusCode: request.ResponseStatusCode, //【返回】状态码 - ResponseContentLength: request.ResponseContentLength, //【返回】大小 - ResponseTime: request.ResponseTime, //【返回】时间 - SdkVersion: go_library.Version(), //【程序】Sdk版本 - } - if !request.HeaderIsImg() { - if len(request.ResponseBody) > 0 { - data.ResponseBody = dorm.JsonEncodeNoError(dorm.JsonDecodeNoError(request.ResponseBody)) //【返回】数据 - } - } - - c.gormRecord(ctx, data) -} diff --git a/utils/golog/error.go b/utils/golog/error.go index 85f4fdae..dc5b0506 100644 --- a/utils/golog/error.go +++ b/utils/golog/error.go @@ -4,5 +4,5 @@ import "errors" var ( currentIpNoConfig = errors.New("请配置 CurrentIp") - dbClientFunNoConfig = errors.New("请配置 GormClientFun 或 MongoClientFun") + dbClientFunNoConfig = errors.New("请配置 GormClientFun") ) diff --git a/utils/golog/gin.go b/utils/golog/gin.go index 7e708677..7040bdbc 100644 --- a/utils/golog/gin.go +++ b/utils/golog/gin.go @@ -45,11 +45,10 @@ type GinClient struct { // GinClientConfig 框架实例配置 type GinClientConfig struct { - IpService *goip.Client // ip服务 - GormClientFun dorm.GormClientTableFun // 日志配置 - MongoClientFun dorm.MongoClientCollectionFun // 日志配置 - ZapLog *ZapLog // 日志服务 - CurrentIp string // 当前ip + IpService *goip.Client // ip服务 + GormClientFun dorm.GormClientTableFun // 日志配置 + ZapLog *ZapLog // 日志服务 + CurrentIp string // 当前ip } // NewGinClient 创建框架实例化