From 495e185e2deb8200f817ddae39c16ff43cabc36d Mon Sep 17 00:00:00 2001 From: Adam Tucker Date: Fri, 26 Jan 2024 03:31:02 -0600 Subject: [PATCH] feat: debug log gRPC queries (#19049) Co-authored-by: Julien Robert --- CHANGELOG.md | 1 + baseapp/baseapp.go | 2 +- baseapp/grpcserver.go | 3 +++ 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8b7dff6defb7..8edd28898dbe 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -49,6 +49,7 @@ Every module contains its own CHANGELOG.md. Please refer to the module you are i * (runtime) [#18475](https://github.com/cosmos/cosmos-sdk/pull/18475) Adds an implementation for core.branch.Service. * (baseapp) [#18499](https://github.com/cosmos/cosmos-sdk/pull/18499) Add `MsgRouter` response type from message name function. * (types) [#18768](https://github.com/cosmos/cosmos-sdk/pull/18768) Add MustValAddressFromBech32 function. +* (gRPC) [#19049](https://github.com/cosmos/cosmos-sdk/pull/19049) Add debug log prints for each gRPC request. ### Improvements diff --git a/baseapp/baseapp.go b/baseapp/baseapp.go index 431f6d482d5c..f4f4444299a1 100644 --- a/baseapp/baseapp.go +++ b/baseapp/baseapp.go @@ -193,7 +193,7 @@ func NewBaseApp( name string, logger log.Logger, db dbm.DB, txDecoder sdk.TxDecoder, options ...func(*BaseApp), ) *BaseApp { app := &BaseApp{ - logger: logger, + logger: logger.With(log.ModuleKey, "baseapp"), name: name, db: db, cms: store.NewCommitMultiStore(db, logger, storemetrics.NewNoOpMetrics()), // by default we use a no-op metric gather in store diff --git a/baseapp/grpcserver.go b/baseapp/grpcserver.go index 20ea6ecac1de..2d11818a462c 100644 --- a/baseapp/grpcserver.go +++ b/baseapp/grpcserver.go @@ -2,6 +2,7 @@ package baseapp import ( "context" + "fmt" "strconv" gogogrpc "github.com/cosmos/gogoproto/grpc" @@ -67,6 +68,8 @@ func (app *BaseApp) RegisterGRPCServer(server gogogrpc.Server) { app.logger.Error("failed to set gRPC header", "err", err) } + app.logger.Debug("gRPC query received of type: " + fmt.Sprintf("%#v", req)) + return handler(grpcCtx, req) }