提交 46585cfa authored 作者: 张立波's avatar 张立波

log

上级 0bcb4bbf
...@@ -86,9 +86,9 @@ func (s *Config) Post(ctx context.Context, method string, params g.Map) (str str ...@@ -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, "Method", "POST")
ctx = context.WithValue(ctx, "URI", Url) ctx = context.WithValue(ctx, "URI", Url)
if err != nil { if err != nil {
g.Log().Async(true).Ctx(ctx).Cat(PkgName).Cat("error").Infof("参数【%v】错误【%v】响应时间【%v】", 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 {
g.Log().Async(true).Ctx(ctx).Cat(PkgName).Infof("参数【%v】响应【%v】响应时间【%v】", paramStr, str, gtime.TimestampMilli()-Start) g.Log().Ctx(ctx).Cat(PkgName).Infof("参数【%v】响应【%v】响应时间【%v ms】", paramStr, str, gtime.TimestampMilli()-Start)
} }
}() }()
str = resp.ReadAllString() str = resp.ReadAllString()
......
...@@ -86,9 +86,9 @@ func (s *Config) Post(ctx context.Context, method string, params g.Map) (str str ...@@ -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, "Method", "POST")
ctx = context.WithValue(ctx, "URI", Url) ctx = context.WithValue(ctx, "URI", Url)
if err != nil { if err != nil {
g.Log().Async(true).Cat(PkgName).Ctx(ctx).Infof("参数【%v】错误【%v】响应时间【%v】", paramStr, err.Error(), gtime.TimestampMilli()-Start) g.Log().Cat(PkgName).Ctx(ctx).Infof("参数【%v】错误【%v】响应时间【%v ms】", paramStr, err.Error(), gtime.TimestampMilli()-Start)
} else { } else {
g.Log().Async(true).Cat(PkgName).Ctx(ctx).Infof("参数【%v】响应【%v】响应时间【%v】", paramStr, str, gtime.TimestampMilli()-Start) g.Log().Cat(PkgName).Ctx(ctx).Infof("参数【%v】响应【%v】响应时间【%v ms】", paramStr, str, gtime.TimestampMilli()-Start)
} }
}() }()
str = resp.ReadAllString() str = resp.ReadAllString()
......
...@@ -86,9 +86,9 @@ func (s *Config) Post(ctx context.Context, method string, params g.Map) (str str ...@@ -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, "Method", "POST")
ctx = context.WithValue(ctx, "URI", Url) ctx = context.WithValue(ctx, "URI", Url)
if err != nil { if err != nil {
g.Log().Async(true).Cat(PkgName).Ctx(ctx).Infof("参数【%v】错误【%v】响应时间【%v】", paramStr, err.Error(), gtime.TimestampMilli()-Start) g.Log().Cat(PkgName).Ctx(ctx).Infof("参数【%v】错误【%v】响应时间【%v ms】", paramStr, err.Error(), gtime.TimestampMilli()-Start)
} else { } else {
g.Log().Async(true).Cat(PkgName).Ctx(ctx).Infof("参数【%v】响应【%v】响应时间【%v】", paramStr, str, gtime.TimestampMilli()-Start) g.Log().Cat(PkgName).Ctx(ctx).Infof("参数【%v】响应【%v】响应时间【%v ms】", paramStr, str, gtime.TimestampMilli()-Start)
} }
}() }()
str = resp.ReadAllString() str = resp.ReadAllString()
......
...@@ -69,8 +69,7 @@ type CommonRes struct { ...@@ -69,8 +69,7 @@ type CommonRes struct {
func post(ctx context.Context, method string, req interface{}) (res *CommonRes, err error) { func post(ctx context.Context, method string, req interface{}) (res *CommonRes, err error) {
//Start := gtime.TimestampMilli() Start := gtime.TimestampMilli()
g.Log().Ctx(ctx).Info(gtime.Now().String())
AccessToken, err := Token.Access(ctx) AccessToken, err := Token.Access(ctx)
if err != nil { if err != nil {
return return
...@@ -94,11 +93,9 @@ func post(ctx context.Context, method string, req interface{}) (res *CommonRes, ...@@ -94,11 +93,9 @@ func post(ctx context.Context, method string, req interface{}) (res *CommonRes,
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 {
g.Log().Ctx(ctx).Info(gtime.Now().String()) g.Log().Ctx(ctx).Cat(PkgName).Cat("error").Infof("参数【%v】错误【%v】响应时间【%v ms】", request.MustToJsonString(), err.Error(), gtime.TimestampMilli()-Start)
//g.Log().Async(true).Ctx(ctx).Cat(PkgName).Cat("error").Infof("参数【%v】错误【%v】响应时间【%v】", request.MustToJsonString(), err.Error(), gtime.TimestampMilli()-Start)
} else { } else {
g.Log().Ctx(ctx).Info(gtime.Now().String()) g.Log().Ctx(ctx).Cat(PkgName).Infof("参数【%v】响应【%v】响应时间【%v ms】", request.MustToJsonString(), str, gtime.TimestampMilli()-Start)
//g.Log().Async(true).Ctx(ctx).Cat(PkgName).Infof("参数【%v】响应【%v】响应时间【%v】", request.MustToJsonString(), str, gtime.TimestampMilli()-Start)
} }
}() }()
str = resp.ReadAllString() str = resp.ReadAllString()
......
...@@ -48,9 +48,9 @@ func post(ctx context.Context, method string, req interface{}) (res string, err ...@@ -48,9 +48,9 @@ func post(ctx context.Context, method string, req interface{}) (res string, err
ctx = context.WithValue(ctx, "Method", "POST") ctx = context.WithValue(ctx, "Method", "POST")
ctx = context.WithValue(ctx, "URI", Url) ctx = context.WithValue(ctx, "URI", Url)
if err != nil { if err != nil {
g.Log().Async(true).Ctx(ctx).Cat(pkgName).Cat("error").Infof("参数【%v】错误【%v】响应时间【%v】", param.MustToJsonString(), err.Error(), gtime.TimestampMilli()-Start) g.Log().Ctx(ctx).Cat(pkgName).Cat("error").Infof("参数【%v】错误【%v】响应时间【%v ms】", param.MustToJsonString(), err.Error(), gtime.TimestampMilli()-Start)
} else { } else {
g.Log().Async(true).Ctx(ctx).Cat(pkgName).Infof("参数【%v】响应【%v】响应时间【%v】", param.MustToJsonString(), res, gtime.TimestampMilli()-Start) g.Log().Ctx(ctx).Cat(pkgName).Infof("参数【%v】响应【%v】响应时间【%v ms】", param.MustToJsonString(), res, gtime.TimestampMilli()-Start)
} }
}() }()
res = resp.ReadAllString() res = resp.ReadAllString()
......
...@@ -64,9 +64,9 @@ func (s *client) post(ctx context.Context, method string, params g.Map) (str str ...@@ -64,9 +64,9 @@ func (s *client) post(ctx context.Context, method string, params g.Map) (str str
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 {
g.Log().Async(true).Ctx(ctx).Cat(pkgName).Cat("error").Infof("参数【%v】错误【%v】响应时间【%v ms】", 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 {
g.Log().Async(true).Ctx(ctx).Cat(pkgName).Infof("参数【%v】响应【%v】响应时间【%v ms】", 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 {
......
...@@ -57,10 +57,10 @@ func (s *Config) Post(ctx context.Context, URL string, bodyMap g.Map) (result st ...@@ -57,10 +57,10 @@ func (s *Config) Post(ctx context.Context, URL string, bodyMap g.Map) (result st
defer func() { defer func() {
ctx = context.WithValue(ctx, "URI", URL) ctx = context.WithValue(ctx, "URI", URL)
if err != nil { if err != nil {
g.Log().Ctx(ctx).Async(true).Cat(pkgName).Cat("error"). g.Log().Ctx(ctx).Cat(pkgName).Cat("error").
Infof("参数【%v】错误【%v】响应时间:【%v ms】", gjson.New(bodyMap).MustToJsonString(), err.Error(), gtime.TimestampMilli()-Start) Infof("参数【%v】错误【%v】响应时间:【%v ms】", gjson.New(bodyMap).MustToJsonString(), err.Error(), gtime.TimestampMilli()-Start)
} else { } else {
g.Log().Ctx(ctx).Async(true).Cat(pkgName). g.Log().Ctx(ctx).Cat(pkgName).
Infof("参数【%v】响应【%v】响应时间:【%v ms】", gjson.New(bodyMap).MustToJsonString(), result, gtime.TimestampMilli()-Start) Infof("参数【%v】响应【%v】响应时间:【%v ms】", gjson.New(bodyMap).MustToJsonString(), result, gtime.TimestampMilli()-Start)
} }
}() }()
......
...@@ -110,9 +110,9 @@ func post(ctx context.Context, method string, params map[string]string) (str str ...@@ -110,9 +110,9 @@ func post(ctx context.Context, method string, params map[string]string) (str str
ctx = context.WithValue(ctx, "Method", "POST") ctx = context.WithValue(ctx, "Method", "POST")
ctx = context.WithValue(ctx, "URI", apiUrl+params["Action"]) ctx = context.WithValue(ctx, "URI", apiUrl+params["Action"])
if err != nil { if err != nil {
g.Log().Ctx(ctx).Async(true).Cat(PkgName).Cat("error").Infof("参数【%v】错误【%v】响应时间【%v】", 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 {
g.Log().Ctx(ctx).Async(true).Cat(PkgName).Infof("参数【%v】响应【%v】响应时间【%v】", paramStr, str, gtime.TimestampMilli()-Start) g.Log().Ctx(ctx).Cat(PkgName).Infof("参数【%v】响应【%v】响应时间【%v ms】", paramStr, str, gtime.TimestampMilli()-Start)
} }
}() }()
str = resp.ReadAllString() str = resp.ReadAllString()
......
...@@ -55,9 +55,9 @@ func log(ctx context.Context, param string, res interface{}, err error) { ...@@ -55,9 +55,9 @@ func log(ctx context.Context, param string, res interface{}, err error) {
start := gtime.TimestampMilli() start := gtime.TimestampMilli()
resString, _ := json.Marshal(res) resString, _ := json.Marshal(res)
if err != nil { if err != nil {
g.Log().Ctx(ctx).Async(true).Cat(logName).Cat("error").Infof("参数【%v】错误【%v】响应时间【%v】", param, err.Error(), gtime.TimestampMilli()-start) g.Log().Ctx(ctx).Cat(logName).Cat("error").Infof("参数【%v】错误【%v】响应时间【%v ms】", param, err.Error(), gtime.TimestampMilli()-start)
} else { } else {
g.Log().Ctx(ctx).Async(true).Cat(logName).Infof("参数【%v】响应【%v】响应时间【%v】", param, string(resString), gtime.TimestampMilli()-start) g.Log().Ctx(ctx).Cat(logName).Infof("参数【%v】响应【%v】响应时间【%v ms】", param, string(resString), gtime.TimestampMilli()-start)
} }
return return
} }
......
...@@ -38,9 +38,9 @@ func New(req *Config) { ...@@ -38,9 +38,9 @@ func New(req *Config) {
func Log(ctx context.Context, req interface{}, res interface{}, err error, start int64) { func Log(ctx context.Context, req interface{}, res interface{}, err error, start int64) {
if err != nil { if err != nil {
g.Log().Ctx(ctx).Async(true).Cat(PkgName).Errorf("参数【%v】错误【%v】响应时间【%vms】", gjson.New(req).MustToJsonString(), err.Error(), gtime.TimestampMilli()-start) g.Log().Ctx(ctx).Cat(PkgName).Errorf("参数【%v】错误【%v】响应时间【%v ms】", gjson.New(req).MustToJsonString(), err.Error(), gtime.TimestampMilli()-start)
} else { } else {
g.Log().Ctx(ctx).Async(true).Cat(PkgName).Infof("参数【%v】响应【%v】响应时间【%vms】", gjson.New(req).MustToJsonString(), gjson.New(res).MustToJsonString(), gtime.TimestampMilli()-start) g.Log().Ctx(ctx).Cat(PkgName).Infof("参数【%v】响应【%v】响应时间【%v ms】", gjson.New(req).MustToJsonString(), gjson.New(res).MustToJsonString(), gtime.TimestampMilli()-start)
} }
} }
......
...@@ -95,9 +95,9 @@ func post(ctx context.Context, method string, req interface{}) (res string, err ...@@ -95,9 +95,9 @@ func post(ctx context.Context, method string, req interface{}) (res string, err
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 {
g.Log().Ctx(ctx).Async(true).Cat(pkgName).Cat("error").Infof("参数【%v】错误【%v】响应时间【%v】", 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 {
g.Log().Ctx(ctx).Async(true).Cat(pkgName).Infof("参数【%v】响应【%v】响应时间【%v】", paramStr, res, gtime.TimestampMilli()-Start) g.Log().Ctx(ctx).Cat(pkgName).Infof("参数【%v】响应【%v】响应时间【%v ms】", paramStr, res, gtime.TimestampMilli()-Start)
} }
}() }()
res = resp.ReadAllString() res = resp.ReadAllString()
......
...@@ -119,9 +119,9 @@ func (s *Client) get(ctx context.Context, method string, params g.Map, xToken .. ...@@ -119,9 +119,9 @@ func (s *Client) get(ctx context.Context, method string, params g.Map, xToken ..
ctx = context.WithValue(ctx, "Method", "GET") ctx = context.WithValue(ctx, "Method", "GET")
ctx = context.WithValue(ctx, "URI", method) ctx = context.WithValue(ctx, "URI", method)
if err != nil { if err != nil {
g.Log().Ctx(ctx).Async(true).Cat(pkgName).Cat("error").Infof("参数【%v】错误【%v】响应时间【%v ms】", 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 {
g.Log().Ctx(ctx).Async(true).Cat(pkgName).Infof("参数【%v】响应【%v】响应时间【%v ms】", 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 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论