Skip to content

Commit

Permalink
rpc: fix time key collision for logger with json output (#24112)
Browse files Browse the repository at this point in the history
The "t" key overrides the log message time in JSON output.

Co-authored-by: Felix Lange <fjl@twurst.com>
  • Loading branch information
bobakxd and fjl authored Dec 15, 2021
1 parent fc01a7c commit 0ba0b81
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions rpc/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -240,7 +240,7 @@ func (h *handler) handleImmediate(msg *jsonrpcMessage) bool {
return false
case msg.isResponse():
h.handleResponse(msg)
h.log.Trace("Handled RPC response", "reqid", idForLog{msg.ID}, "t", time.Since(start))
h.log.Trace("Handled RPC response", "reqid", idForLog{msg.ID}, "duration", time.Since(start))
return true
default:
return false
Expand Down Expand Up @@ -292,12 +292,12 @@ func (h *handler) handleCallMsg(ctx *callProc, msg *jsonrpcMessage) *jsonrpcMess
switch {
case msg.isNotification():
h.handleCall(ctx, msg)
h.log.Debug("Served "+msg.Method, "t", time.Since(start))
h.log.Debug("Served "+msg.Method, "duration", time.Since(start))
return nil
case msg.isCall():
resp := h.handleCall(ctx, msg)
var ctx []interface{}
ctx = append(ctx, "reqid", idForLog{msg.ID}, "t", time.Since(start))
ctx = append(ctx, "reqid", idForLog{msg.ID}, "duration", time.Since(start))
if resp.Error != nil {
ctx = append(ctx, "err", resp.Error.Message)
if resp.Error.Data != nil {
Expand Down

0 comments on commit 0ba0b81

Please sign in to comment.