From e7ca47c2804c69aef754fdac50e20647d780b55d Mon Sep 17 00:00:00 2001 From: Daniel Liu <139250065@qq.com> Date: Thu, 24 Apr 2025 18:35:18 +0800 Subject: [PATCH] rpc: fix time key collision for logger with json output #24112 (#963) The "t" key overrides the log message time in JSON output. Co-authored-by: Roman Mazalov <83914728+gopherxyz@users.noreply.github.com> Co-authored-by: Felix Lange --- rpc/handler.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/rpc/handler.go b/rpc/handler.go index f28ea4cb85..9770f4860f 100644 --- a/rpc/handler.go +++ b/rpc/handler.go @@ -239,7 +239,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 @@ -291,12 +291,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 {