Skip to content

Commit

Permalink
增加 err 错误打印请求和返回数据
Browse files Browse the repository at this point in the history
  • Loading branch information
JellyTony committed Sep 27, 2024
1 parent 47b01f4 commit 02cd41a
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions middleware/logging/logging.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,10 +204,10 @@ func Client(opts ...Option) middleware.Middleware {
"duration": timex.Duration(duration),
"callee_service": callee,
}
if cfg.dumpReq {
if cfg.dumpReq || err != nil {
fields["request"] = extractArgs(req)
}
if cfg.dumpResp {
if cfg.dumpResp || err != nil {
fields["response"] = extractArgs(resp)
}
if nodeAddress != "" {
Expand Down Expand Up @@ -354,10 +354,10 @@ func Server(opts ...Option) middleware.Middleware {
"duration": timex.Duration(duration),
"caller_service": caller,
}
if cfg.dumpReq {
if cfg.dumpReq || err != nil {
fields["request"] = extractArgs(req)
}
if cfg.dumpResp {
if cfg.dumpResp || err != nil {
fields["response"] = extractArgs(resp)
}
if se := errors.FromError(err); se != nil {
Expand Down

0 comments on commit 02cd41a

Please sign in to comment.