提交 86576e49 authored 作者: 张立波's avatar 张立波

淘特

上级 4e25155e
......@@ -86,9 +86,9 @@ func (s *Config) Post(ctx context.Context, method string, params g.Map) (str str
ctx = context.WithValue(ctx, "Method", "POST")
ctx = context.WithValue(ctx, "URI", Url)
if err != nil {
g.Log().Cat(PkgName).Ctx(ctx).Infof("参数【%v】错误【%v】响应时间【%v】", paramStr, err.Error(), gtime.TimestampMilli()-Start)
g.Log().Ctx(ctx).Cat(PkgName).Cat("error").Infof("参数【%v】错误【%v】响应时间【%v】", paramStr, err.Error(), gtime.TimestampMilli()-Start)
} else {
g.Log().Cat(PkgName).Ctx(ctx).Infof("参数【%v】响应【%v】响应时间【%v】", str, gtime.TimestampMilli()-Start)
g.Log().Ctx(ctx).Cat(PkgName).Infof("参数【%v】响应【%v】响应时间【%v】", str, gtime.TimestampMilli()-Start)
}
}()
str = resp.ReadAllString()
......
......@@ -15,6 +15,7 @@ type Config struct {
AppKey string
AppSecret string
API string
DB int
}
var server *Config
......@@ -24,6 +25,9 @@ const CacheKey = "dwd:token"
func New(req *Config) {
server = req
if server.DB == 0 {
server.DB = 10
}
return
}
......@@ -89,7 +93,7 @@ func post(ctx context.Context, method string, req interface{}) (res *CommonRes,
ctx = context.WithValue(ctx, "Method", "POST")
ctx = context.WithValue(ctx, "URI", method)
if err != nil {
g.Log().Ctx(ctx).Infof("参数【%v】错误【%v】响应时间【%v】", request.MustToJsonString(), err.Error(), gtime.TimestampMilli()-Start)
g.Log().Ctx(ctx).Cat(PkgName).Cat("error").Infof("参数【%v】错误【%v】响应时间【%v】", request.MustToJsonString(), err.Error(), gtime.TimestampMilli()-Start)
} else {
g.Log().Ctx(ctx).Cat(PkgName).Infof("参数【%v】响应【%v】响应时间【%v】", request.MustToJsonString(), str, gtime.TimestampMilli()-Start)
}
......
......@@ -52,7 +52,7 @@ func (s *tokenDwd) Access(ctx context.Context) (res string, err error) {
defer func() {
_ = conn.Close()
}()
_, _ = conn.DoVar("SELECT", 10)
_, _ = conn.DoVar("SELECT", server.DB)
cache, _ := conn.DoVar("HGETALL", CacheKey)
if !cache.IsEmpty() {
_ = cache.Scan(&s)
......@@ -90,7 +90,7 @@ func (s *tokenDwd) post(ctx context.Context, req interface{}) (res string, err e
ctx = context.WithValue(ctx, "Method", "POST")
ctx = context.WithValue(ctx, "URI", "token")
if err != nil {
g.Log().Ctx(ctx).Infof("参数【%v】错误【%v】响应时间【%v】", request.MustToJsonString(), err.Error(), gtime.TimestampMilli()-Start)
g.Log().Ctx(ctx).Cat(PkgName).Cat("error").Infof("参数【%v】错误【%v】响应时间【%v】", request.MustToJsonString(), err.Error(), gtime.TimestampMilli()-Start)
} else {
g.Log().Ctx(ctx).Cat(PkgName).Infof("参数【%v】响应【%v】响应时间【%v】", request.MustToJsonString(), res, gtime.TimestampMilli()-Start)
}
......
......@@ -48,7 +48,7 @@ func post(ctx context.Context, method string, req interface{}) (res string, err
ctx = context.WithValue(ctx, "Method", "POST")
ctx = context.WithValue(ctx, "URI", Url)
if err != nil {
g.Log().Ctx(ctx).Infof("参数【%v】错误【%v】响应时间【%v】", param.MustToJsonString(), err.Error(), gtime.TimestampMilli()-Start)
g.Log().Ctx(ctx).Cat(pkgName).Cat("error").Infof("参数【%v】错误【%v】响应时间【%v】", param.MustToJsonString(), err.Error(), gtime.TimestampMilli()-Start)
} else {
g.Log().Ctx(ctx).Cat(pkgName).Infof("参数【%v】响应【%v】响应时间【%v】", param.MustToJsonString(), res, gtime.TimestampMilli()-Start)
}
......
......@@ -46,10 +46,10 @@ func (c *Config) Post(ctx context.Context, api string, bodyMap g.Map) (result st
defer func() {
ctx = context.WithValue(ctx, "URI", api)
if err != nil {
g.Log().Ctx(ctx).Cat("error").Async(true).
g.Log().Ctx(ctx).Cat(pkgName).Cat("error").
Infof("参数【%v】错误【%v】响应时间:【%v ms】", gjson.New(bodyMap).MustToJsonString(), err.Error(), gtime.TimestampMilli()-Start)
} else {
g.Log().Ctx(ctx).Cat(pkgName).Async(true).
g.Log().Ctx(ctx).Cat(pkgName).
Infof("参数【%v】响应【%v】响应时间:【%v ms】", gjson.New(bodyMap).MustToJsonString(), result, gtime.TimestampMilli()-Start)
}
}()
......
......@@ -110,7 +110,7 @@ func post(ctx context.Context, method string, params map[string]string) (str str
ctx = context.WithValue(ctx, "Method", "POST")
ctx = context.WithValue(ctx, "URI", apiUrl+params["Action"])
if err != nil {
g.Log().Ctx(ctx).Infof("参数【%v】错误【%v】响应时间【%v】", paramStr, err.Error(), gtime.TimestampMilli()-Start)
g.Log().Ctx(ctx).Cat(PkgName).Cat("error").Infof("参数【%v】错误【%v】响应时间【%v】", paramStr, err.Error(), gtime.TimestampMilli()-Start)
} else {
g.Log().Ctx(ctx).Cat(PkgName).Infof("参数【%v】响应【%v】响应时间【%v】", paramStr, str, gtime.TimestampMilli()-Start)
}
......
......@@ -95,7 +95,7 @@ func post(ctx context.Context, method string, req interface{}) (res string, err
ctx = context.WithValue(ctx, "Method", "POST")
ctx = context.WithValue(ctx, "URI", method)
if err != nil {
g.Log().Ctx(ctx).Infof("参数【%v】错误【%v】响应时间【%v】", paramStr, err.Error(), gtime.TimestampMilli()-Start)
g.Log().Ctx(ctx).Cat(pkgName).Cat("error").Infof("参数【%v】错误【%v】响应时间【%v】", paramStr, err.Error(), gtime.TimestampMilli()-Start)
} else {
g.Log().Ctx(ctx).Cat(pkgName).Infof("参数【%v】响应【%v】响应时间【%v】", paramStr, res, gtime.TimestampMilli()-Start)
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论