Skip to content

Commit 0ba0b81

Browse files
bobakxdfjl
andauthored
rpc: fix time key collision for logger with json output (#24112)
The "t" key overrides the log message time in JSON output. Co-authored-by: Felix Lange <[email protected]>
1 parent fc01a7c commit 0ba0b81

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

rpc/handler.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ func (h *handler) handleImmediate(msg *jsonrpcMessage) bool {
240240
return false
241241
case msg.isResponse():
242242
h.handleResponse(msg)
243-
h.log.Trace("Handled RPC response", "reqid", idForLog{msg.ID}, "t", time.Since(start))
243+
h.log.Trace("Handled RPC response", "reqid", idForLog{msg.ID}, "duration", time.Since(start))
244244
return true
245245
default:
246246
return false
@@ -292,12 +292,12 @@ func (h *handler) handleCallMsg(ctx *callProc, msg *jsonrpcMessage) *jsonrpcMess
292292
switch {
293293
case msg.isNotification():
294294
h.handleCall(ctx, msg)
295-
h.log.Debug("Served "+msg.Method, "t", time.Since(start))
295+
h.log.Debug("Served "+msg.Method, "duration", time.Since(start))
296296
return nil
297297
case msg.isCall():
298298
resp := h.handleCall(ctx, msg)
299299
var ctx []interface{}
300-
ctx = append(ctx, "reqid", idForLog{msg.ID}, "t", time.Since(start))
300+
ctx = append(ctx, "reqid", idForLog{msg.ID}, "duration", time.Since(start))
301301
if resp.Error != nil {
302302
ctx = append(ctx, "err", resp.Error.Message)
303303
if resp.Error.Data != nil {

0 commit comments

Comments
 (0)