Skip to content

Commit 84b52a5

Browse files
rpc daemon: log request params on debug verbosity (#1087)
* rpc_daemon_access_log * rpc_daemon_access_log * clean * remove response * remove accesslog concept * clean
1 parent bdb7832 commit 84b52a5

File tree

2 files changed

+6
-9
lines changed

2 files changed

+6
-9
lines changed

cmd/rpcdaemon/cli/config.go

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@ package cli
33
import (
44
"context"
55
"fmt"
6-
"net/http"
7-
86
"github.com/ledgerwatch/turbo-geth/cmd/utils"
97
"github.com/ledgerwatch/turbo-geth/ethdb"
108
"github.com/ledgerwatch/turbo-geth/internal/debug"
119
"github.com/ledgerwatch/turbo-geth/log"
1210
"github.com/ledgerwatch/turbo-geth/node"
1311
"github.com/ledgerwatch/turbo-geth/rpc"
1412
"github.com/spf13/cobra"
13+
"net/http"
1514
)
1615

1716
type Flags struct {
@@ -103,8 +102,7 @@ func StartRpcServer(ctx context.Context, cfg Flags, rpcAPI []rpc.API) error {
103102
wsHandler = srv.WebsocketHandler([]string{"*"})
104103
}
105104

106-
handler := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
107-
105+
var handler http.Handler = http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
108106
if cfg.WebsocketEnabled && r.Method == "GET" {
109107
wsHandler.ServeHTTP(w, r)
110108
}

rpc/handler.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -292,21 +292,20 @@ 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", "t", time.Since(start), "method", msg.Method, "params", string(msg.Params))
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, "method", msg.Method, "reqid", idForLog{msg.ID}, "t", time.Since(start))
301301
if resp.Error != nil {
302302
ctx = append(ctx, "err", resp.Error.Message)
303303
if resp.Error.Data != nil {
304304
ctx = append(ctx, "errdata", resp.Error.Data)
305305
}
306-
h.log.Warn("Served "+msg.Method, ctx...)
307-
} else {
308-
h.log.Debug("Served "+msg.Method, ctx...)
306+
h.log.Warn("Served", ctx...)
309307
}
308+
h.log.Debug("Served", "t", time.Since(start), "method", msg.Method, "reqid", idForLog{msg.ID}, "params", string(msg.Params))
310309
return resp
311310
case msg.hasValidID():
312311
return msg.errorResponse(&invalidRequestError{"invalid request"})

0 commit comments

Comments
 (0)