提交 730b3de3 authored 作者: zhanglibo's avatar zhanglibo

京东

上级 bbc98451
...@@ -7,7 +7,6 @@ import ( ...@@ -7,7 +7,6 @@ import (
"github.com/gogf/gf/frame/g" "github.com/gogf/gf/frame/g"
"github.com/gogf/gf/os/gtime" "github.com/gogf/gf/os/gtime"
"github.com/gogf/gf/util/gconv" "github.com/gogf/gf/util/gconv"
"gitlab.jxhh.com/stbz/library.git/logs"
"strings" "strings"
"time" "time"
) )
...@@ -60,14 +59,13 @@ func (s *client) post(ctx context.Context, method string, params g.Map) (str str ...@@ -60,14 +59,13 @@ func (s *client) post(ctx context.Context, method string, params g.Map) (str str
Request.SetHeader("Content-Type", "application/x-www-form-urlencoded") Request.SetHeader("Content-Type", "application/x-www-form-urlencoded")
resp, err := Request.Timeout(time.Second*5).Post(method, params) resp, err := Request.Timeout(time.Second*5).Post(method, params)
defer func() { defer func() {
_ = resp.Body.Close()
paramStr := gjson.New(params).MustToJsonString() paramStr := gjson.New(params).MustToJsonString()
ctx = context.WithValue(ctx, "Method", "POST") ctx = context.WithValue(ctx, "Method", "POST")
ctx = context.WithValue(ctx, "URI", method) ctx = context.WithValue(ctx, "URI", method)
if err != nil { if err != nil {
logs.Errorf(ctx, logs.FormatErr, paramStr, err.Error(), gtime.TimestampMilli()-Start) g.Log().Ctx(ctx).Cat(pkgName).Cat("error").Infof("参数【%v】错误【%v】响应时间【%v ms】", paramStr, err.Error(), gtime.TimestampMilli()-Start)
} else { } else {
logs.Infof(ctx, pkgName, logs.FormatSuc, paramStr, str, gtime.TimestampMilli()-Start) g.Log().Ctx(ctx).Cat(pkgName).Infof("参数【%v】响应【%v】响应时间【%v ms】", paramStr, str, gtime.TimestampMilli()-Start)
} }
}() }()
if err != nil { if err != nil {
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论