添加请求JSON日志记录功能

- 引入g.Log()模块用于日志记录
- 在JSON序列化前添加清理后JSON数据的日志输出
- 提升调试和问题排查能力
menu v1.0.8
maguodong 2025-10-16 15:36:38 +08:00
parent 9813be8873
commit 90f319f763
1 changed files with 2 additions and 0 deletions

View File

@ -16,6 +16,7 @@ import (
"github.com/black1552/base-common/utils"
"github.com/gogf/gf/v2/encoding/gjson"
"github.com/gogf/gf/v2/frame/g"
"github.com/gogf/gf/v2/os/gfile"
"github.com/gogf/gf/v2/util/gconv"
)
@ -100,6 +101,7 @@ func (c *Client[T]) DoRequest(url string, reqData interface{}) (*T, error) {
if err != nil {
return nil, fmt.Errorf("清理JSON空值失败: %v", err)
}
g.Log().Infof(c.ctx, "清理后的json: %s", reqJson)
// 序列化为JSON
jsonData, err := json.Marshal(reqJson)
if err != nil {