Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: debug log gRPC queries #19049

Merged
merged 10 commits into from
Jan 26, 2024
Prev Previous commit
Next Next commit
add baseapp module key to logger
  • Loading branch information
czarcas7ic committed Jan 24, 2024
commit 1c00bb741d8d52a30fafa996959f46cede7acb80
3 changes: 2 additions & 1 deletion runtime/builder.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"encoding/json"
"io"

"cosmossdk.io/log"
dbm "github.com/cosmos/cosmos-db"

"github.com/cosmos/cosmos-sdk/baseapp"
Expand All @@ -29,7 +30,7 @@ func (a *AppBuilder) Build(db dbm.DB, traceStore io.Writer, baseAppOptions ...fu
baseAppOptions = append(baseAppOptions, option)
}

bApp := baseapp.NewBaseApp(a.app.config.AppName, a.app.logger, db, nil, baseAppOptions...)
bApp := baseapp.NewBaseApp(a.app.config.AppName, a.app.logger.With(log.ModuleKey, "baseapp"), db, nil, baseAppOptions...)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would do it automatically in NewBaseApp itself

bApp.SetMsgServiceRouter(a.app.msgServiceRouter)
bApp.SetCommitMultiStoreTracer(traceStore)
bApp.SetVersion(version.Version)
Expand Down
2 changes: 1 addition & 1 deletion simapp/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -248,7 +248,7 @@ func NewSimApp(
}
baseAppOptions = append(baseAppOptions, voteExtOp, baseapp.SetOptimisticExecution())

bApp := baseapp.NewBaseApp(appName, logger, db, txConfig.TxDecoder(), baseAppOptions...)
bApp := baseapp.NewBaseApp(appName, logger.With(log.ModuleKey, "baseapp"), db, txConfig.TxDecoder(), baseAppOptions...)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tip

Codebase Verification

The verification process has identified that the logger with the module key "baseapp" is used in simapp/app.go and also in simapp/app_test.go. However, the usage in app_test.go uses a different key ("instance" instead of log.ModuleKey). This indicates that the logger is not used consistently with the module key "baseapp" across the application.

Analysis chain

The NewSimApp function has been modified to include a logger with a module key "baseapp". This change is consistent with the PR objectives and should enhance logging within the baseapp instance. Ensure that the logger is correctly instantiated and that the module key "baseapp" is used consistently across the application.

Scripts Executed

The following scripts were executed for the analysis:


Script:

#!/bin/bash
# Verify that the logger with the module key "baseapp" is used consistently across the application.
ast-grep --lang go --pattern $'logger.With("ModuleKey", "baseapp")'

Length of output: 68



Script:

#!/bin/bash
# Search for any usage of logger.With with any string literal as the module key to check for "baseapp" usage.
ast-grep --lang go --pattern $'logger.With($_, "baseapp")'

Length of output: 332

bApp.SetCommitMultiStoreTracer(traceStore)
bApp.SetVersion(version.Version)
bApp.SetInterfaceRegistry(interfaceRegistry)
Expand Down
Loading