diff --git a/baseapp/grpcrouter_test.go b/baseapp/grpcrouter_test.go index 860e7bbe75c..dede24b7bc1 100644 --- a/baseapp/grpcrouter_test.go +++ b/baseapp/grpcrouter_test.go @@ -2,11 +2,10 @@ package baseapp_test import ( "context" - "os" "sync" "testing" - "github.com/cometbft/cometbft/libs/log" + "cosmossdk.io/log" dbm "github.com/cosmos/cosmos-db" "github.com/stretchr/testify/require" @@ -59,7 +58,7 @@ func TestRegisterQueryServiceTwice(t *testing.T) { err := depinject.Inject(makeMinimalConfig(), &appBuilder) require.NoError(t, err) db := dbm.NewMemDB() - app := appBuilder.Build(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil) + app := appBuilder.Build(log.NewLogger(), db, nil) // First time registering service shouldn't panic. require.NotPanics(t, func() { diff --git a/baseapp/msg_service_router_test.go b/baseapp/msg_service_router_test.go index 45e4832b1a1..c361af9d667 100644 --- a/baseapp/msg_service_router_test.go +++ b/baseapp/msg_service_router_test.go @@ -1,16 +1,15 @@ package baseapp_test import ( - "os" "testing" abci "github.com/cometbft/cometbft/abci/types" - "github.com/cometbft/cometbft/libs/log" cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" dbm "github.com/cosmos/cosmos-db" "github.com/stretchr/testify/require" "cosmossdk.io/depinject" + "cosmossdk.io/log" "github.com/cosmos/cosmos-sdk/client/tx" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -29,7 +28,7 @@ func TestRegisterMsgService(t *testing.T) { ) err := depinject.Inject(makeMinimalConfig(), &appBuilder, ®istry) require.NoError(t, err) - app := appBuilder.Build(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), dbm.NewMemDB(), nil) + app := appBuilder.Build(log.NewLogger(), dbm.NewMemDB(), nil) require.Panics(t, func() { testdata.RegisterMsgServer( @@ -58,7 +57,7 @@ func TestRegisterMsgServiceTwice(t *testing.T) { err := depinject.Inject(makeMinimalConfig(), &appBuilder, ®istry) require.NoError(t, err) db := dbm.NewMemDB() - app := appBuilder.Build(log.NewTMLogger(log.NewSyncWriter(os.Stdout)), db, nil) + app := appBuilder.Build(log.NewLogger(), db, nil) testdata.RegisterInterfaces(registry) // First time registering service shouldn't panic. diff --git a/baseapp/utils_test.go b/baseapp/utils_test.go index 53eb3cfaab3..60da5286736 100644 --- a/baseapp/utils_test.go +++ b/baseapp/utils_test.go @@ -8,7 +8,6 @@ import ( "errors" "fmt" "net/url" - "os" "reflect" "strconv" "testing" @@ -55,7 +54,7 @@ var ParamStoreKey = []byte("paramstore") func defaultLogger() log.Logger { if testing.Verbose() { - return log.NewTMLogger(log.NewSyncWriter(os.Stdout)).With("module", "baseapp/test") + return log.NewLoggerWithKV("module", "baseapp/test") } return log.NewNopLogger() diff --git a/client/pruning/main.go b/client/pruning/main.go index 0a3d6f0e8a6..ec996ef5dd0 100644 --- a/client/pruning/main.go +++ b/client/pruning/main.go @@ -2,15 +2,14 @@ package pruning import ( "fmt" - "os" "path/filepath" "github.com/spf13/cobra" "github.com/spf13/viper" + "cosmossdk.io/log" pruningtypes "cosmossdk.io/store/pruning/types" "cosmossdk.io/store/rootmulti" - "github.com/cometbft/cometbft/libs/log" dbm "github.com/cosmos/cosmos-db" "github.com/cosmos/cosmos-sdk/client/flags" @@ -62,7 +61,7 @@ func Cmd(appCreator servertypes.AppCreator) *cobra.Command { return err } - logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout)) + logger := log.NewLogger() app := appCreator(logger, db, nil, vp) cms := app.CommitMultiStore() diff --git a/go.mod b/go.mod index fe27932eb50..f26546800dd 100644 --- a/go.mod +++ b/go.mod @@ -46,6 +46,7 @@ require ( github.com/prometheus/client_golang v1.14.0 github.com/prometheus/common v0.40.0 github.com/rakyll/statik v0.1.7 + github.com/rs/zerolog v1.29.0 github.com/spf13/cast v1.5.0 github.com/spf13/cobra v1.6.1 github.com/spf13/pflag v1.0.5 @@ -136,7 +137,6 @@ require ( github.com/rcrowley/go-metrics v0.0.0-20201227073835-cf1acfcdf475 // indirect github.com/rogpeppe/go-internal v1.9.0 // indirect github.com/rs/cors v1.8.3 // indirect - github.com/rs/zerolog v1.29.0 // indirect github.com/sasha-s/go-deadlock v0.3.1 // indirect github.com/spf13/afero v1.9.3 // indirect github.com/spf13/jwalterweatherman v1.1.0 // indirect diff --git a/log/README.md b/log/README.md index e019c03bea4..c06f26e933b 100644 --- a/log/README.md +++ b/log/README.md @@ -1,3 +1,3 @@ # Log -The `cosmossdk.io/log` provides simple logging implementations for the Cosmos SDK and Cosmos SDK modules. \ No newline at end of file +The `cosmossdk.io/log` provides a zerolog logging implementation for the Cosmos SDK and Cosmos SDK modules. diff --git a/log/go.mod b/log/go.mod index fa553c0fc7d..e98e6470b17 100644 --- a/log/go.mod +++ b/log/go.mod @@ -2,16 +2,10 @@ module cosmossdk.io/log go 1.19 -require ( - github.com/cometbft/cometbft v0.37.0-alpha.3 - github.com/rs/zerolog v1.29.0 -) +require github.com/rs/zerolog v1.29.0 require ( - github.com/go-kit/log v0.2.1 // indirect - github.com/go-logfmt/logfmt v0.5.1 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.16 // indirect - github.com/pkg/errors v0.9.1 // indirect golang.org/x/sys v0.5.0 // indirect ) diff --git a/log/go.sum b/log/go.sum index 3c6c29508e3..f2a3d868ecd 100644 --- a/log/go.sum +++ b/log/go.sum @@ -1,11 +1,4 @@ -github.com/cometbft/cometbft v0.37.0-alpha.3 h1:74F+cMr4pd1a2lFn/h4TxXmO8VWi3A2dxyoMcjlMWuQ= -github.com/cometbft/cometbft v0.37.0-alpha.3/go.mod h1:dUGbIGYoLM11xUruTTJY4Xp9FHh6Nfu3Nots8/+UNSo= github.com/coreos/go-systemd/v22 v22.3.3-0.20220203105225-a9a7ef127534/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= -github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= -github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU= -github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= -github.com/go-logfmt/logfmt v0.5.1 h1:otpy5pqBCBZ1ng9RQ0dPu4PN7ba75Y/aA+UpowDyNVA= -github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= @@ -13,16 +6,12 @@ github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovk github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= github.com/mattn/go-isatty v0.0.16 h1:bq3VjFmv/sOjHtdEhmkEV4x1AJtvUvOJ2PFAZ5+peKQ= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/rs/xid v1.4.0/go.mod h1:trrq9SKmegXys3aeAKXMUTdJsYXVwGY3RLcfgqegfbg= github.com/rs/zerolog v1.29.0 h1:Zes4hju04hjbvkVkOhdl2HpZa+0PmVwigmo8XoORE5w= github.com/rs/zerolog v1.29.0/go.mod h1:NILgTygv/Uej1ra5XxGf82ZFSLk58MFGAUS2o6usyD0= -github.com/stretchr/testify v1.8.1 h1:w7B6lhMri9wdJUVmEZPGGhZzrYTPvgJArz7wNPgYKsk= golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.5.0 h1:MUK/U/4lj1t1oPg0HfuXDN/Z1wv31ZJ/YcPiGccS4DU= golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/log/logger.go b/log/logger.go index 812d1e8fa20..2ac4c7cd903 100644 --- a/log/logger.go +++ b/log/logger.go @@ -1,12 +1,65 @@ package log -import cmtlog "github.com/cometbft/cometbft/libs/log" +import ( + "os" + "time" + + "github.com/rs/zerolog" +) + +// Defines commons keys for logging +const ModuleKey = "module" + +// ContextKey is used to store the logger in the context +var ContextKey struct{} -// Logger is the interface that wraps the basic logging methods. type Logger interface { - Debug(msg string, keyvals ...interface{}) - Info(msg string, keyvals ...interface{}) - Error(msg string, keyvals ...interface{}) + Info(msg string, keyVals ...interface{}) + Error(msg string, keyVals ...interface{}) + Debug(msg string, keyVals ...interface{}) + With(keyVals ...interface{}) Logger +} + +type ZeroLogWrapper struct { + zerolog.Logger +} + +func NewNopLogger() Logger { + logger := zerolog.Nop() + return &ZeroLogWrapper{logger} +} + +func NewLogger() Logger { + output := zerolog.ConsoleWriter{Out: os.Stdout, TimeFormat: time.Kitchen} + logger := zerolog.New(output).With().Timestamp().Logger() + return &ZeroLogWrapper{logger} +} + +func NewLoggerWithKV(key, value string) Logger { + output := zerolog.ConsoleWriter{Out: os.Stdout, TimeFormat: time.Kitchen} + logger := zerolog.New(output).With().Str(key, value).Timestamp().Logger() + return &ZeroLogWrapper{logger} +} + +// Info takes a message and a set of key/value pairs and logs with level INFO. +// The key of the tuple must be a string. +func (l ZeroLogWrapper) Info(msg string, keyVals ...interface{}) { + l.Logger.Info().Fields(keyVals).Msg(msg) +} + +// Error takes a message and a set of key/value pairs and logs with level DEBUG. +// The key of the tuple must be a string. +func (l ZeroLogWrapper) Error(msg string, keyVals ...interface{}) { + l.Logger.Error().Fields(keyVals).Msg(msg) +} + +// Debug takes a message and a set of key/value pairs and logs with level ERR. +// The key of the tuple must be a string. +func (l ZeroLogWrapper) Debug(msg string, keyVals ...interface{}) { + l.Logger.Debug().Fields(keyVals).Msg(msg) +} - With(keyvals ...interface{}) cmtlog.Logger +// With returns a new wrapped logger with additional context provided by a set +func (l ZeroLogWrapper) With(keyVals ...interface{}) Logger { + return ZeroLogWrapper{l.Logger.With().Fields(keyVals).Logger()} } diff --git a/log/noop_logger.go b/log/noop_logger.go deleted file mode 100644 index a1ffb0a8334..00000000000 --- a/log/noop_logger.go +++ /dev/null @@ -1,19 +0,0 @@ -package log - -import cmlog "github.com/cometbft/cometbft/libs/log" - -var _ Logger = NoOp{} - -type NoOp struct{} - -func NewNopLogger() Logger { - return &NoOp{} -} - -func (l NoOp) Debug(msg string, keyvals ...interface{}) {} -func (l NoOp) Info(msg string, keyvals ...interface{}) {} -func (l NoOp) Error(msg string, keyvals ...interface{}) {} - -func (l NoOp) With(i ...interface{}) cmlog.Logger { - return l -} diff --git a/log/zerolog.go b/log/zerolog.go deleted file mode 100644 index d3d60105d55..00000000000 --- a/log/zerolog.go +++ /dev/null @@ -1,60 +0,0 @@ -package log - -import ( - "os" - "time" - - cmtlog "github.com/cometbft/cometbft/libs/log" - "github.com/rs/zerolog" -) - -// Defines commons keys for logging -const ModuleKey = "module" - -var ( - // ContextKey is used to store the logger in the context - ContextKey struct{} - _ Logger = (*ZeroLogWrapper)(nil) -) - -func NewZeroLogger(key, value string) *zerolog.Logger { - output := zerolog.ConsoleWriter{Out: os.Stdout, TimeFormat: time.Kitchen} - logger := zerolog.New(output).With().Str(key, value).Timestamp().Logger() - return &logger -} - -// TODO: add filtered logging in ZeroLog: https://github.com/cosmos/cosmos-sdk/pull/13236 / https://github.com/cosmos/cosmos-sdk/issues/13699#issuecomment-1354887644 - -// ZeroLogWrapper provides a wrapper around a zerolog.Logger instance. It implements -// Tendermint's Logger interface. -type ZeroLogWrapper struct { - zerolog.Logger -} - -// Info implements Tendermint's Logger interface and logs with level INFO. A set -// of key/value tuples may be provided to add context to the log. The number of -// tuples must be even and the key of the tuple must be a string. -func (z ZeroLogWrapper) Info(msg string, keyVals ...interface{}) { - z.Logger.Info().Fields(keyVals).Msg(msg) -} - -// Error implements Tendermint's Logger interface and logs with level ERR. A set -// of key/value tuples may be provided to add context to the log. The number of -// tuples must be even and the key of the tuple must be a string. -func (z ZeroLogWrapper) Error(msg string, keyVals ...interface{}) { - z.Logger.Error().Fields(keyVals).Msg(msg) -} - -// Debug implements Tendermint's Logger interface and logs with level DEBUG. A set -// of key/value tuples may be provided to add context to the log. The number of -// tuples must be even and the key of the tuple must be a string. -func (z ZeroLogWrapper) Debug(msg string, keyVals ...interface{}) { - z.Logger.Debug().Fields(keyVals).Msg(msg) -} - -// With returns a new wrapped logger with additional context provided by a set -// of key/value tuples. The number of tuples must be even and the key of the -// tuple must be a string. -func (z ZeroLogWrapper) With(keyVals ...interface{}) cmtlog.Logger { - return ZeroLogWrapper{z.Logger.With().Fields(keyVals).Logger()} -} diff --git a/scripts/mockgen.sh b/scripts/mockgen.sh index 8906d0a07b8..a3786acc50d 100755 --- a/scripts/mockgen.sh +++ b/scripts/mockgen.sh @@ -7,7 +7,7 @@ $mockgen_cmd -source=types/module/module.go -package mock -destination testutil/ $mockgen_cmd -source=types/module/mock_appmodule_test.go -package mock -destination testutil/mock/types_mock_appmodule.go $mockgen_cmd -source=types/invariant.go -package mock -destination testutil/mock/types_invariant.go $mockgen_cmd -package mock -destination testutil/mock/grpc_server.go github.com/cosmos/gogoproto/grpc Server -$mockgen_cmd -package mock -destination testutil/mock/cometbft_log.go github.com/cometbft/cometbft/libs/log Logger +$mockgen_cmd -package mock -destination testutil/mock/logger.go cosmossdk.io/log Logger $mockgen_cmd -source=orm/model/ormtable/hooks.go -package ormmocks -destination orm/testing/ormmocks/hooks.go $mockgen_cmd -source=x/nft/expected_keepers.go -package testutil -destination x/nft/testutil/expected_keepers_mocks.go $mockgen_cmd -source=x/feegrant/expected_keepers.go -package testutil -destination x/feegrant/testutil/expected_keepers_mocks.go diff --git a/server/cmt_logger.go b/server/cmt_logger.go new file mode 100644 index 00000000000..50cd609df4e --- /dev/null +++ b/server/cmt_logger.go @@ -0,0 +1,21 @@ +package server + +import ( + "cosmossdk.io/log" + cmtlog "github.com/cometbft/cometbft/libs/log" +) + +var _ cmtlog.Logger = (*CometZerologWrapper)(nil) + +// CometZerologWrapper provides a wrapper around a zerolog.Logger instance. +// It implements CometBFT's Logger interface. +type CometZerologWrapper struct { + log.ZeroLogWrapper +} + +// With returns a new wrapped logger with additional context provided by a set +// of key/value tuples. The number of tuples must be even and the key of the +// tuple must be a string. +func (cmt CometZerologWrapper) With(keyVals ...interface{}) cmtlog.Logger { + return cmt.With(keyVals...) +} diff --git a/server/mock/app.go b/server/mock/app.go index b1d78dcfd85..5c977b53d21 100644 --- a/server/mock/app.go +++ b/server/mock/app.go @@ -8,10 +8,10 @@ import ( "path/filepath" abci "github.com/cometbft/cometbft/abci/types" - "github.com/cometbft/cometbft/libs/log" db "github.com/cosmos/cosmos-db" "google.golang.org/grpc" + "cosmossdk.io/log" storetypes "cosmossdk.io/store/types" bam "github.com/cosmos/cosmos-sdk/baseapp" diff --git a/server/mock/helpers.go b/server/mock/helpers.go index 2d29bc494e6..42f5ad984ea 100644 --- a/server/mock/helpers.go +++ b/server/mock/helpers.go @@ -5,18 +5,18 @@ import ( "os" "testing" + "cosmossdk.io/log" abci "github.com/cometbft/cometbft/abci/types" - cmtlog "github.com/cometbft/cometbft/libs/log" ) // SetupApp returns an application as well as a clean-up function to be used to // quickly setup a test case with an app. func SetupApp() (abci.Application, func(), error) { - var logger cmtlog.Logger + var logger log.Logger if testing.Verbose() { - logger = cmtlog.NewTMLogger(cmtlog.NewSyncWriter(os.Stdout)).With("module", "mock") + logger = log.NewLoggerWithKV("module", "mock") } else { - logger = cmtlog.NewNopLogger() + logger = log.NewNopLogger() } rootDir, err := os.MkdirTemp("", "mock-sdk") diff --git a/server/util.go b/server/util.go index 4281bb54624..b54035b1ab7 100644 --- a/server/util.go +++ b/server/util.go @@ -15,11 +15,6 @@ import ( "syscall" "time" - "cosmossdk.io/log" - "cosmossdk.io/store" - "cosmossdk.io/store/snapshots" - snapshottypes "cosmossdk.io/store/snapshots/types" - storetypes "cosmossdk.io/store/types" cmtcmd "github.com/cometbft/cometbft/cmd/cometbft/commands" cmtcfg "github.com/cometbft/cometbft/config" cmtcli "github.com/cometbft/cometbft/libs/cli" @@ -31,6 +26,12 @@ import ( "github.com/spf13/pflag" "github.com/spf13/viper" + "cosmossdk.io/log" + "cosmossdk.io/store" + "cosmossdk.io/store/snapshots" + snapshottypes "cosmossdk.io/store/snapshots/types" + storetypes "cosmossdk.io/store/types" + "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/server/config" @@ -48,7 +49,7 @@ const ServerContextKey = sdk.ContextKey("server.context") type Context struct { Viper *viper.Viper Config *cmtcfg.Config - Logger cmtlog.Logger + Logger log.Logger } // ErrorCode contains the exit code for server exit. @@ -64,11 +65,11 @@ func NewDefaultContext() *Context { return NewContext( viper.New(), cmtcfg.DefaultConfig(), - cmtlog.NewTMLogger(cmtlog.NewSyncWriter(os.Stdout)), + log.NewLogger(), ) } -func NewContext(v *viper.Viper, config *cmtcfg.Config, logger cmtlog.Logger) *Context { +func NewContext(v *viper.Viper, config *cmtcfg.Config, logger log.Logger) *Context { return &Context{v, config, logger} } diff --git a/simapp/app_test.go b/simapp/app_test.go index 08b84e489ac..882d35e6df5 100644 --- a/simapp/app_test.go +++ b/simapp/app_test.go @@ -3,19 +3,18 @@ package simapp import ( "encoding/json" "fmt" - "os" "testing" "cosmossdk.io/x/evidence" "cosmossdk.io/x/upgrade" abci "github.com/cometbft/cometbft/abci/types" - "github.com/cometbft/cometbft/libs/log" cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" dbm "github.com/cosmos/cosmos-db" "github.com/cosmos/gogoproto/proto" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" + "cosmossdk.io/log" feegrantmodule "cosmossdk.io/x/feegrant/module" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/testutil/mock" @@ -41,7 +40,7 @@ import ( func TestSimAppExportAndBlockedAddrs(t *testing.T) { db := dbm.NewMemDB() - logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout)) + logger := log.NewLogger() app := NewSimappWithCustomOptions(t, false, SetupOptions{ Logger: logger, DB: db, @@ -66,7 +65,7 @@ func TestSimAppExportAndBlockedAddrs(t *testing.T) { app.Commit() - logger2 := log.NewTMLogger(log.NewSyncWriter(os.Stdout)) + logger2 := log.NewLogger() // Making a new app object with the db, so that initchain hasn't been called app2 := NewSimApp(logger2, db, nil, true, simtestutil.NewAppOptionsWithFlagHome(t.TempDir())) _, err := app2.ExportAppStateAndValidators(false, []string{}, []string{}) @@ -75,7 +74,7 @@ func TestSimAppExportAndBlockedAddrs(t *testing.T) { func TestRunMigrations(t *testing.T) { db := dbm.NewMemDB() - logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout)) + logger := log.NewLogger() app := NewSimApp(logger, db, nil, true, simtestutil.NewAppOptionsWithFlagHome(t.TempDir())) // Create a new baseapp and configurator for the purpose of this test. @@ -209,7 +208,7 @@ func TestRunMigrations(t *testing.T) { func TestInitGenesisOnMigration(t *testing.T) { db := dbm.NewMemDB() - logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout)) + logger := log.NewLogger() app := NewSimApp(logger, db, nil, true, simtestutil.NewAppOptionsWithFlagHome(t.TempDir())) ctx := app.NewContext(true, cmtproto.Header{Height: app.LastBlockHeight()}) @@ -252,7 +251,7 @@ func TestInitGenesisOnMigration(t *testing.T) { func TestUpgradeStateOnGenesis(t *testing.T) { db := dbm.NewMemDB() - logger := log.NewTMLogger(log.NewSyncWriter(os.Stdout)) + logger := log.NewLogger() app := NewSimappWithCustomOptions(t, false, SetupOptions{ Logger: logger, DB: db, diff --git a/simapp/sim_test.go b/simapp/sim_test.go index e104e62a513..dae3d023767 100644 --- a/simapp/sim_test.go +++ b/simapp/sim_test.go @@ -11,11 +11,11 @@ import ( evidencetypes "cosmossdk.io/x/evidence/types" abci "github.com/cometbft/cometbft/abci/types" - "github.com/cometbft/cometbft/libs/log" cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" dbm "github.com/cosmos/cosmos-db" "github.com/stretchr/testify/require" + "cosmossdk.io/log" "cosmossdk.io/store" storetypes "cosmossdk.io/store/types" diff --git a/simapp/simd/cmd/testnet_test.go b/simapp/simd/cmd/testnet_test.go index 4905d634ac7..d7b05f685cb 100644 --- a/simapp/simd/cmd/testnet_test.go +++ b/simapp/simd/cmd/testnet_test.go @@ -5,10 +5,10 @@ import ( "fmt" "testing" - "github.com/cometbft/cometbft/libs/log" "github.com/spf13/viper" "github.com/stretchr/testify/require" + "cosmossdk.io/log" "cosmossdk.io/simapp" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" diff --git a/store/go.mod b/store/go.mod index a31784523e0..6f426c5edcd 100644 --- a/store/go.mod +++ b/store/go.mod @@ -38,8 +38,6 @@ require ( github.com/decred/dcrd/dcrec/secp256k1/v4 v4.1.0 // indirect github.com/fsnotify/fsnotify v1.6.0 // indirect github.com/getsentry/sentry-go v0.18.0 // indirect - github.com/go-kit/log v0.2.1 // indirect - github.com/go-logfmt/logfmt v0.5.1 // indirect github.com/gogo/protobuf v1.3.2 // indirect github.com/golang/snappy v0.0.4 // indirect github.com/google/btree v1.1.2 // indirect @@ -77,3 +75,5 @@ require ( // Fix upstream GHSA-h395-qcrw-5vmq vulnerability. // TODO Remove it: https://github.com/cosmos/cosmos-sdk/issues/10409 replace github.com/gin-gonic/gin => github.com/gin-gonic/gin v1.8.1 + +replace cosmossdk.io/log => ../log diff --git a/store/go.sum b/store/go.sum index 4a8e62a7959..a1b7e3d8935 100644 --- a/store/go.sum +++ b/store/go.sum @@ -1,8 +1,6 @@ cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cosmossdk.io/errors v1.0.0-beta.7 h1:gypHW76pTQGVnHKo6QBkb4yFOJjC+sUGRc5Al3Odj1w= cosmossdk.io/errors v1.0.0-beta.7/go.mod h1:mz6FQMJRku4bY7aqS/Gwfcmr/ue91roMEKAmDUDpBfE= -cosmossdk.io/log v0.0.0-20230219145338-9553bf1eec78 h1:Scox9JfANgkuAO0F9LMH0e0W5ijmp2BQbsok/U+jDUo= -cosmossdk.io/log v0.0.0-20230219145338-9553bf1eec78/go.mod h1:MyvZ6k9eL0azI/yf8m5gqsM8PgbtFmqjire1OxUMkmc= cosmossdk.io/math v1.0.0-beta.6.0.20230216172121-959ce49135e4 h1:/jnzJ9zFsL7qkV8LCQ1JH3dYHh2EsKZ3k8Mr6AqqiOA= cosmossdk.io/math v1.0.0-beta.6.0.20230216172121-959ce49135e4/go.mod h1:gUVtWwIzfSXqcOT+lBVz2jyjfua8DoBdzRsIyaUAT/8= github.com/AndreasBriese/bbloom v0.0.0-20190306092124-e2d15f34fcf9/go.mod h1:bOvUY6CB00SOBii9/FifXqc0awNKxLFCL/+pkDPuyl8= @@ -104,12 +102,8 @@ github.com/go-errors/errors v1.0.1/go.mod h1:f4zRHt4oKfwPJE5k8C9vpYG+aDHdBFUsgrm github.com/go-errors/errors v1.4.2 h1:J6MZopCL4uSllY1OfXM374weqZFFItUbrImctkmUxIA= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/log v0.2.1 h1:MRVx0/zhvdseW+Gza6N9rVzU/IVzaeE1SFI4raAhmBU= -github.com/go-kit/log v0.2.1/go.mod h1:NwTd00d/i8cPZ3xOwwiv2PO5MOcx78fFErGNcVmBjv0= github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= -github.com/go-logfmt/logfmt v0.5.1 h1:otpy5pqBCBZ1ng9RQ0dPu4PN7ba75Y/aA+UpowDyNVA= -github.com/go-logfmt/logfmt v0.5.1/go.mod h1:WYhtIu8zTZfxdn5+rREduYbwxfcBr/Vr6KEVveWlfTs= github.com/go-martini/martini v0.0.0-20170121215854-22fa46961aab/go.mod h1:/P9AEU963A2AYjv4d1V5eVL1CQbEJq6aCNHDDjibzu8= github.com/go-playground/assert/v2 v2.0.1/go.mod h1:VDjEfimB/XKnb+ZQfWdccd7VUvScMdVu0Titje2rxJ4= github.com/go-playground/locales v0.14.0/go.mod h1:sawfccIbzZTqEDETgFXqTho0QybSa7l++s0DH+LDiLs= diff --git a/store/iavl/store.go b/store/iavl/store.go index 5b55b526048..2bd523194f7 100644 --- a/store/iavl/store.go +++ b/store/iavl/store.go @@ -6,13 +6,13 @@ import ( "io" abci "github.com/cometbft/cometbft/abci/types" - "github.com/cometbft/cometbft/libs/log" cmtprotocrypto "github.com/cometbft/cometbft/proto/tendermint/crypto" ics23 "github.com/confio/ics23/go" dbm "github.com/cosmos/cosmos-db" "github.com/cosmos/iavl" errorsmod "cosmossdk.io/errors" + "cosmossdk.io/log" "cosmossdk.io/store/cachekv" "cosmossdk.io/store/internal/kv" "cosmossdk.io/store/metrics" diff --git a/store/snapshots/manager_test.go b/store/snapshots/manager_test.go index 4756a6a8d58..a3e9e35957b 100644 --- a/store/snapshots/manager_test.go +++ b/store/snapshots/manager_test.go @@ -4,10 +4,10 @@ import ( "errors" "testing" - "github.com/cometbft/cometbft/libs/log" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "cosmossdk.io/log" "cosmossdk.io/store/snapshots" "cosmossdk.io/store/snapshots/types" ) diff --git a/store/store.go b/store/store.go index 04f28521c60..e6745754639 100644 --- a/store/store.go +++ b/store/store.go @@ -1,9 +1,9 @@ package store import ( - "github.com/cometbft/cometbft/libs/log" dbm "github.com/cosmos/cosmos-db" + "cosmossdk.io/log" "cosmossdk.io/store/cache" "cosmossdk.io/store/metrics" "cosmossdk.io/store/rootmulti" diff --git a/store/streaming/constructor.go b/store/streaming/constructor.go index fdf22497ecf..acfe2cd2e7e 100644 --- a/store/streaming/constructor.go +++ b/store/streaming/constructor.go @@ -7,9 +7,9 @@ import ( "strings" "sync" + "cosmossdk.io/log" "cosmossdk.io/store/streaming/file" "cosmossdk.io/store/types" - "github.com/cometbft/cometbft/libs/log" "github.com/spf13/cast" ) diff --git a/store/streaming/constructor_test.go b/store/streaming/constructor_test.go index cdb6fc6db5e..aacc4f79d78 100644 --- a/store/streaming/constructor_test.go +++ b/store/streaming/constructor_test.go @@ -3,9 +3,9 @@ package streaming_test import ( "testing" - "github.com/cometbft/cometbft/libs/log" "github.com/stretchr/testify/require" + "cosmossdk.io/log" "cosmossdk.io/store/streaming" "cosmossdk.io/store/streaming/file" "cosmossdk.io/store/types" diff --git a/store/streaming/file/service_test.go b/store/streaming/file/service_test.go index ff901dc8e6c..ba71d4eda7d 100644 --- a/store/streaming/file/service_test.go +++ b/store/streaming/file/service_test.go @@ -11,10 +11,10 @@ import ( "testing" abci "github.com/cometbft/cometbft/abci/types" - "github.com/cometbft/cometbft/libs/log" cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" "github.com/stretchr/testify/require" + "cosmossdk.io/log" "cosmossdk.io/store/types" ) diff --git a/tests/e2e/server/export_test.go b/tests/e2e/server/export_test.go index 11f2a190abc..72a75736ae2 100644 --- a/tests/e2e/server/export_test.go +++ b/tests/e2e/server/export_test.go @@ -14,7 +14,6 @@ import ( "testing" abci "github.com/cometbft/cometbft/abci/types" - cmtlog "github.com/cometbft/cometbft/libs/log" cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" dbm "github.com/cosmos/cosmos-db" "github.com/spf13/cobra" @@ -158,7 +157,7 @@ func setupApp(t *testing.T, tempDir string) (*simapp.SimApp, context.Context, ge err := createConfigFolder(tempDir) assert.NilError(t, err) - logger := cmtlog.NewTMLogger(cmtlog.NewSyncWriter(os.Stdout)) + logger := log.NewLogger() db := dbm.NewMemDB() app := simapp.NewSimApp(logger, db, nil, true, simtestutil.NewAppOptionsWithFlagHome(tempDir)) diff --git a/testutil/mock/cometbft_log.go b/testutil/mock/logger.go similarity index 97% rename from testutil/mock/cometbft_log.go rename to testutil/mock/logger.go index 437e11332a7..117eb4db860 100644 --- a/testutil/mock/cometbft_log.go +++ b/testutil/mock/logger.go @@ -1,5 +1,5 @@ // Code generated by MockGen. DO NOT EDIT. -// Source: github.com/cometbft/cometbft/libs/log (interfaces: Logger) +// Source: cosmossdk.io/log (interfaces: Logger) // Package mock is a generated GoMock package. package mock diff --git a/testutil/network/network.go b/testutil/network/network.go index 347d0d317b2..72f7439307c 100644 --- a/testutil/network/network.go +++ b/testutil/network/network.go @@ -20,7 +20,6 @@ import ( sdkmath "cosmossdk.io/math" "cosmossdk.io/math/unsafe" pruningtypes "cosmossdk.io/store/pruning/types" - cmtlog "github.com/cometbft/cometbft/libs/log" "github.com/cometbft/cometbft/node" cmtclient "github.com/cometbft/cometbft/rpc/client" dbm "github.com/cosmos/cosmos-db" @@ -119,7 +118,7 @@ type Config struct { StakingTokens sdkmath.Int // the amount of tokens each validator has available to stake BondedTokens sdkmath.Int // the amount of tokens each validator stakes PruningStrategy string // the pruning strategy each validator will have - EnableTMLogging bool // enable CometBFT logging to STDOUT + EnableLogging bool // enable logging to STDOUT CleanupDir bool // remove base temporary directory during cleanup SigningAlgo string // signing algorithm for keys KeyringOptions []keyring.Option // keyring configuration options @@ -406,8 +405,8 @@ func New(l Logger, baseDir string, cfg Config) (*Network, error) { } logger := log.NewNopLogger() - if cfg.EnableTMLogging { - logger = cmtlog.NewTMLogger(cmtlog.NewSyncWriter(os.Stdout)) + if cfg.EnableLogging { + logger = log.NewLogger() } ctx.Logger = logger diff --git a/testutil/sims/app_helpers.go b/testutil/sims/app_helpers.go index 7c168719b62..0dc3a91e714 100644 --- a/testutil/sims/app_helpers.go +++ b/testutil/sims/app_helpers.go @@ -9,11 +9,11 @@ import ( sdkmath "cosmossdk.io/math" abci "github.com/cometbft/cometbft/abci/types" cmtjson "github.com/cometbft/cometbft/libs/json" - "github.com/cometbft/cometbft/libs/log" cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" cmttypes "github.com/cometbft/cometbft/types" dbm "github.com/cosmos/cosmos-db" + "cosmossdk.io/log" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/codec" codectypes "github.com/cosmos/cosmos-sdk/codec/types" diff --git a/testutil/sims/simulation_helpers.go b/testutil/sims/simulation_helpers.go index 848e1c875d0..790392a5230 100644 --- a/testutil/sims/simulation_helpers.go +++ b/testutil/sims/simulation_helpers.go @@ -6,9 +6,9 @@ import ( "fmt" "os" - "github.com/cometbft/cometbft/libs/log" dbm "github.com/cosmos/cosmos-db" + "cosmossdk.io/log" storetypes "cosmossdk.io/store/types" "github.com/cosmos/cosmos-sdk/codec" @@ -29,7 +29,7 @@ func SetupSimulation(config simtypes.Config, dirPrefix, dbName string, verbose, var logger log.Logger if verbose { - logger = log.TestingLogger() + logger = log.NewLogger() } else { logger = log.NewNopLogger() } diff --git a/tools/cosmovisor/cmd/cosmovisor/main.go b/tools/cosmovisor/cmd/cosmovisor/main.go index 95d51a194fb..70e14d08388 100644 --- a/tools/cosmovisor/cmd/cosmovisor/main.go +++ b/tools/cosmovisor/cmd/cosmovisor/main.go @@ -9,7 +9,7 @@ import ( ) func main() { - logger := log.NewZeroLogger(log.ModuleKey, "cosmovisor") + logger := log.NewLoggerWithKV(log.ModuleKey, "cosmovisor") ctx := context.WithValue(context.Background(), log.ContextKey, logger) if err := rootCmd.ExecuteContext(ctx); err != nil { diff --git a/tools/cosmovisor/cmd/cosmovisor/version_test.go b/tools/cosmovisor/cmd/cosmovisor/version_test.go index 193ec8a1542..8f8188a2a82 100644 --- a/tools/cosmovisor/cmd/cosmovisor/version_test.go +++ b/tools/cosmovisor/cmd/cosmovisor/version_test.go @@ -10,7 +10,7 @@ import ( ) func TestVersionCommand_Error(t *testing.T) { - logger := log.NewZeroLogger(log.ModuleKey, "cosmovisor") + logger := log.NewLoggerWithKV(log.ModuleKey, "cosmovisor") rootCmd.SetArgs([]string{"version"}) diff --git a/tools/cosmovisor/errors/multi.go b/tools/cosmovisor/errors/multi.go index 297cfdf1f4d..7a57a06b6b2 100644 --- a/tools/cosmovisor/errors/multi.go +++ b/tools/cosmovisor/errors/multi.go @@ -2,9 +2,8 @@ package errors import ( "fmt" + "log" "strings" - - "github.com/rs/zerolog" ) // MultiError is an error combining multiple other errors. @@ -70,7 +69,7 @@ func (e MultiError) String() string { return e.Error() } -func LogErrors(logger *zerolog.Logger, msg string, err error) { +func LogErrors(logger log.Logger, msg string, err error) { switch err := err.(type) { case *MultiError: if msg != "" { diff --git a/tools/cosmovisor/process.go b/tools/cosmovisor/process.go index b7199603c14..c5f6edb44a9 100644 --- a/tools/cosmovisor/process.go +++ b/tools/cosmovisor/process.go @@ -4,6 +4,7 @@ import ( "encoding/json" "fmt" "io" + "log" "os" "os/exec" "os/signal" @@ -14,19 +15,18 @@ import ( "time" "github.com/otiai10/copy" - "github.com/rs/zerolog" "cosmossdk.io/x/upgrade/plan" upgradetypes "cosmossdk.io/x/upgrade/types" ) type Launcher struct { - logger *zerolog.Logger + logger log.Logger cfg *Config fw *fileWatcher } -func NewLauncher(logger *zerolog.Logger, cfg *Config) (Launcher, error) { +func NewLauncher(logger log.Logger, cfg *Config) (Launcher, error) { fw, err := newUpgradeFileWatcher(logger, cfg.UpgradeInfoFilePath(), cfg.PollInterval) if err != nil { return Launcher{}, err diff --git a/tools/cosmovisor/process_test.go b/tools/cosmovisor/process_test.go index b25f1828cb9..d2089e7fb5d 100644 --- a/tools/cosmovisor/process_test.go +++ b/tools/cosmovisor/process_test.go @@ -31,7 +31,7 @@ func (s *processTestSuite) TestLaunchProcess() { require := s.Require() home := copyTestData(s.T(), "validate") cfg := &cosmovisor.Config{Home: home, Name: "dummyd", PollInterval: 20, UnsafeSkipBackup: true} - logger := log.NewZeroLogger(log.ModuleKey, "cosmovisor") + logger := log.NewLoggerWithKV(log.ModuleKey, "cosmovisor") // should run the genesis binary and produce expected output stdout, stderr := NewBuffer(), NewBuffer() @@ -75,7 +75,7 @@ func (s *processTestSuite) TestLaunchProcessWithRestartDelay() { require := s.Require() home := copyTestData(s.T(), "validate") cfg := &cosmovisor.Config{Home: home, Name: "dummyd", RestartDelay: 5 * time.Second, PollInterval: 20, UnsafeSkipBackup: true} - logger := log.NewZeroLogger(log.ModuleKey, "cosmovisor") + logger := log.NewLoggerWithKV(log.ModuleKey, "cosmovisor") // should run the genesis binary and produce expected output stdout, stderr := NewBuffer(), NewBuffer() @@ -111,7 +111,7 @@ func (s *processTestSuite) TestLaunchProcessWithDownloads() { require := s.Require() home := copyTestData(s.T(), "download") cfg := &cosmovisor.Config{Home: home, Name: "autod", AllowDownloadBinaries: true, PollInterval: 100, UnsafeSkipBackup: true} - logger := log.NewZeroLogger(log.ModuleKey, "cosmovisor") + logger := log.NewLoggerWithKV(log.ModuleKey, "cosmovisor") upgradeFilename := cfg.UpgradeInfoFilePath() // should run the genesis binary and produce expected output diff --git a/tools/cosmovisor/scanner.go b/tools/cosmovisor/scanner.go index 49fab0ccb58..f1ae841561e 100644 --- a/tools/cosmovisor/scanner.go +++ b/tools/cosmovisor/scanner.go @@ -4,17 +4,17 @@ import ( "encoding/json" "errors" "fmt" + "log" "os" "path/filepath" "strings" "time" upgradetypes "cosmossdk.io/x/upgrade/types" - "github.com/rs/zerolog" ) type fileWatcher struct { - logger *zerolog.Logger + logger log.Logger // full path to a watched file filename string @@ -29,7 +29,7 @@ type fileWatcher struct { initialized bool } -func newUpgradeFileWatcher(logger *zerolog.Logger, filename string, interval time.Duration) (*fileWatcher, error) { +func newUpgradeFileWatcher(logger log.Logger, filename string, interval time.Duration) (*fileWatcher, error) { if filename == "" { return nil, errors.New("filename undefined") } diff --git a/tools/cosmovisor/upgrade.go b/tools/cosmovisor/upgrade.go index 501811d444f..dfe05efba5d 100644 --- a/tools/cosmovisor/upgrade.go +++ b/tools/cosmovisor/upgrade.go @@ -3,18 +3,18 @@ package cosmovisor import ( "errors" "fmt" + "log" "os" "runtime" "cosmossdk.io/x/upgrade/plan" upgradetypes "cosmossdk.io/x/upgrade/types" - "github.com/rs/zerolog" ) // UpgradeBinary will be called after the log message has been parsed and the process has terminated. // We can now make any changes to the underlying directory without interference and leave it // in a state, so we can make a proper restart -func UpgradeBinary(logger *zerolog.Logger, cfg *Config, p upgradetypes.Plan) error { +func UpgradeBinary(logger log.Logger, cfg *Config, p upgradetypes.Plan) error { // simplest case is to switch the link err := plan.EnsureBinary(cfg.UpgradeBin(p.Name)) if err == nil { diff --git a/tools/cosmovisor/upgrade_test.go b/tools/cosmovisor/upgrade_test.go index 540f420401c..3b976a75399 100644 --- a/tools/cosmovisor/upgrade_test.go +++ b/tools/cosmovisor/upgrade_test.go @@ -94,7 +94,7 @@ func (s *upgradeTestSuite) assertCurrentLink(cfg cosmovisor.Config, target strin func (s *upgradeTestSuite) TestUpgradeBinaryNoDownloadUrl() { home := copyTestData(s.T(), "validate") cfg := &cosmovisor.Config{Home: home, Name: "dummyd", AllowDownloadBinaries: true} - logger := log.NewZeroLogger(log.ModuleKey, "cosmovisor") + logger := log.NewLoggerWithKV(log.ModuleKey, "cosmovisor") currentBin, err := cfg.CurrentBin() s.Require().NoError(err) @@ -127,7 +127,7 @@ func (s *upgradeTestSuite) TestUpgradeBinaryNoDownloadUrl() { } func (s *upgradeTestSuite) TestUpgradeBinary() { - logger := log.NewZeroLogger(log.ModuleKey, "cosmovisor") + logger := log.NewLoggerWithKV(log.ModuleKey, "cosmovisor") cases := map[string]struct { url string diff --git a/tools/rosetta/cmd/rosetta/main.go b/tools/rosetta/cmd/rosetta/main.go index 8cd21b6d003..e0f075b8487 100644 --- a/tools/rosetta/cmd/rosetta/main.go +++ b/tools/rosetta/cmd/rosetta/main.go @@ -11,7 +11,7 @@ import ( func main() { var ( - logger = log.NewZeroLogger(log.ModuleKey, "rosetta") + logger = log.NewLoggerWithKV(log.ModuleKey, "rosetta") interfaceRegistry = codectypes.NewInterfaceRegistry() cdc = codec.NewProtoCodec(interfaceRegistry) ) diff --git a/tools/rosetta/lib/server/server.go b/tools/rosetta/lib/server/server.go index 9e0aaf1633b..e2a4c240290 100644 --- a/tools/rosetta/lib/server/server.go +++ b/tools/rosetta/lib/server/server.go @@ -61,7 +61,7 @@ func NewServer(settings Settings) (Server, error) { return Server{}, fmt.Errorf("cannot build asserter: %w", err) } - logger := log.NewZeroLogger(log.ModuleKey, "rosetta") + logger := log.NewLoggerWithKV(log.ModuleKey, "rosetta") var adapter crgtypes.API switch settings.Offline { @@ -95,7 +95,7 @@ func newOfflineAdapter(settings Settings) (crgtypes.API, error) { return service.NewOffline(settings.Network, settings.Client) } -func newOnlineAdapter(settings Settings, logger *zerolog.Logger) (crgtypes.API, error) { +func newOnlineAdapter(settings Settings, logger log.Logger) (crgtypes.API, error) { if settings.Client == nil { return nil, fmt.Errorf("client is nil") } diff --git a/types/mempool/mempool_test.go b/types/mempool/mempool_test.go index 744ff066df3..2d544192b87 100644 --- a/types/mempool/mempool_test.go +++ b/types/mempool/mempool_test.go @@ -5,11 +5,11 @@ import ( "math/rand" "testing" - "github.com/cometbft/cometbft/libs/log" cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" + "cosmossdk.io/log" cryptotypes "github.com/cosmos/cosmos-sdk/crypto/types" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/mempool" diff --git a/types/mempool/priority_nonce_test.go b/types/mempool/priority_nonce_test.go index 88910c36c0b..6c00bf58ede 100644 --- a/types/mempool/priority_nonce_test.go +++ b/types/mempool/priority_nonce_test.go @@ -7,10 +7,10 @@ import ( "testing" "time" - "github.com/cometbft/cometbft/libs/log" cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" "github.com/stretchr/testify/require" + "cosmossdk.io/log" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/mempool" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" diff --git a/types/mempool/sender_nonce_test.go b/types/mempool/sender_nonce_test.go index 69a21a10a6c..bcaca96529b 100644 --- a/types/mempool/sender_nonce_test.go +++ b/types/mempool/sender_nonce_test.go @@ -5,10 +5,10 @@ import ( "math/rand" "testing" - "github.com/cometbft/cometbft/libs/log" cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" "github.com/stretchr/testify/require" + "cosmossdk.io/log" sdk "github.com/cosmos/cosmos-sdk/types" "github.com/cosmos/cosmos-sdk/types/mempool" simtypes "github.com/cosmos/cosmos-sdk/types/simulation" diff --git a/types/module/module_test.go b/types/module/module_test.go index e77e21fa207..055810c7edd 100644 --- a/types/module/module_test.go +++ b/types/module/module_test.go @@ -8,8 +8,8 @@ import ( "testing" "cosmossdk.io/core/appmodule" + "cosmossdk.io/log" abci "github.com/cometbft/cometbft/abci/types" - "github.com/cometbft/cometbft/libs/log" cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" "github.com/golang/mock/gomock" "github.com/spf13/cobra" diff --git a/x/auth/migrations/legacytx/stdtx_test.go b/x/auth/migrations/legacytx/stdtx_test.go index 626bc6f1ac4..f8fb9ee99b2 100644 --- a/x/auth/migrations/legacytx/stdtx_test.go +++ b/x/auth/migrations/legacytx/stdtx_test.go @@ -4,12 +4,11 @@ import ( "fmt" "testing" - "github.com/cometbft/cometbft/libs/log" cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" "github.com/stretchr/testify/require" errorsmod "cosmossdk.io/errors" - + "cosmossdk.io/log" "github.com/cosmos/cosmos-sdk/codec" cryptocodec "github.com/cosmos/cosmos-sdk/crypto/codec" "github.com/cosmos/cosmos-sdk/crypto/keys/ed25519" diff --git a/x/authz/keeper/keeper_test.go b/x/authz/keeper/keeper_test.go index 13768dc0d17..226b4c67a82 100644 --- a/x/authz/keeper/keeper_test.go +++ b/x/authz/keeper/keeper_test.go @@ -9,8 +9,8 @@ import ( "github.com/golang/mock/gomock" "github.com/stretchr/testify/suite" + "cosmossdk.io/log" storetypes "cosmossdk.io/store/types" - "github.com/cometbft/cometbft/libs/log" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/testutil" diff --git a/x/genutil/client/cli/genaccount_test.go b/x/genutil/client/cli/genaccount_test.go index 13e83647de5..3de35946d7e 100644 --- a/x/genutil/client/cli/genaccount_test.go +++ b/x/genutil/client/cli/genaccount_test.go @@ -5,10 +5,10 @@ import ( "fmt" "testing" - "github.com/cometbft/cometbft/libs/log" "github.com/spf13/viper" "github.com/stretchr/testify/require" + "cosmossdk.io/log" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/crypto/hd" diff --git a/x/genutil/client/cli/init_test.go b/x/genutil/client/cli/init_test.go index ae935d887ab..db37e5430b4 100644 --- a/x/genutil/client/cli/init_test.go +++ b/x/genutil/client/cli/init_test.go @@ -11,10 +11,10 @@ import ( abci_server "github.com/cometbft/cometbft/abci/server" "github.com/cometbft/cometbft/libs/cli" - "github.com/cometbft/cometbft/libs/log" "github.com/spf13/viper" "github.com/stretchr/testify/require" + "cosmossdk.io/log" "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/client/flags" "github.com/cosmos/cosmos-sdk/codec" diff --git a/x/genutil/client/testutil/helpers.go b/x/genutil/client/testutil/helpers.go index 489404ae155..c570b9a6d08 100644 --- a/x/genutil/client/testutil/helpers.go +++ b/x/genutil/client/testutil/helpers.go @@ -6,9 +6,10 @@ import ( cmtcfg "github.com/cometbft/cometbft/config" "github.com/cometbft/cometbft/libs/cli" - "github.com/cometbft/cometbft/libs/log" "github.com/spf13/viper" + "cosmossdk.io/log" + "github.com/cosmos/cosmos-sdk/client" "github.com/cosmos/cosmos-sdk/codec" "github.com/cosmos/cosmos-sdk/server" diff --git a/x/group/keeper/genesis_test.go b/x/group/keeper/genesis_test.go index 93f2667c9c7..33a59cb5231 100644 --- a/x/group/keeper/genesis_test.go +++ b/x/group/keeper/genesis_test.go @@ -6,10 +6,10 @@ import ( "testing" "time" - "github.com/cometbft/cometbft/libs/log" "github.com/golang/mock/gomock" "github.com/stretchr/testify/suite" + "cosmossdk.io/log" storetypes "cosmossdk.io/store/types" "github.com/cosmos/cosmos-sdk/baseapp" diff --git a/x/group/keeper/grpc_query_test.go b/x/group/keeper/grpc_query_test.go index ff21f01cd7c..a5716575151 100644 --- a/x/group/keeper/grpc_query_test.go +++ b/x/group/keeper/grpc_query_test.go @@ -4,10 +4,10 @@ import ( "context" "testing" - "github.com/cometbft/cometbft/libs/log" "github.com/golang/mock/gomock" "github.com/stretchr/testify/require" + "cosmossdk.io/log" storetypes "cosmossdk.io/store/types" "github.com/cosmos/cosmos-sdk/baseapp" diff --git a/x/group/keeper/keeper.go b/x/group/keeper/keeper.go index 22a871f3dea..73df21e9372 100644 --- a/x/group/keeper/keeper.go +++ b/x/group/keeper/keeper.go @@ -4,8 +4,7 @@ import ( "fmt" "time" - "github.com/cometbft/cometbft/libs/log" - + "cosmossdk.io/log" storetypes "cosmossdk.io/store/types" errorsmod "cosmossdk.io/errors" diff --git a/x/group/keeper/keeper_test.go b/x/group/keeper/keeper_test.go index 66b023dfae8..35e160c0c9b 100644 --- a/x/group/keeper/keeper_test.go +++ b/x/group/keeper/keeper_test.go @@ -10,11 +10,11 @@ import ( "testing" "time" - "github.com/cometbft/cometbft/libs/log" cmttime "github.com/cometbft/cometbft/types/time" "github.com/golang/mock/gomock" "github.com/stretchr/testify/suite" + "cosmossdk.io/log" storetypes "cosmossdk.io/store/types" "github.com/cosmos/cosmos-sdk/baseapp" diff --git a/x/upgrade/abci_test.go b/x/upgrade/abci_test.go index dcaedcf37d9..aee58f0202e 100644 --- a/x/upgrade/abci_test.go +++ b/x/upgrade/abci_test.go @@ -11,11 +11,11 @@ import ( "github.com/stretchr/testify/require" "github.com/stretchr/testify/suite" + "cosmossdk.io/log" storetypes "cosmossdk.io/store/types" "cosmossdk.io/x/upgrade" "cosmossdk.io/x/upgrade/keeper" "cosmossdk.io/x/upgrade/types" - "github.com/cometbft/cometbft/libs/log" "github.com/cosmos/cosmos-sdk/baseapp" "github.com/cosmos/cosmos-sdk/testutil" diff --git a/x/upgrade/go.mod b/x/upgrade/go.mod index 990d77ed012..b8f6ad606e1 100644 --- a/x/upgrade/go.mod +++ b/x/upgrade/go.mod @@ -7,6 +7,7 @@ require ( cosmossdk.io/core v0.5.1 cosmossdk.io/depinject v1.0.0-alpha.3 cosmossdk.io/errors v1.0.0-beta.7 + cosmossdk.io/log v0.0.0-20230219145338-9553bf1eec78 cosmossdk.io/store v0.0.0-20230206092147-e03195e4b8a7 github.com/cometbft/cometbft v0.37.0-alpha.3 github.com/cosmos/cosmos-db v1.0.0-rc.1 @@ -32,7 +33,6 @@ require ( cloud.google.com/go/iam v0.11.0 // indirect cloud.google.com/go/storage v1.29.0 // indirect cosmossdk.io/collections v0.0.0-20230214153846-b6c6e4e99177 // indirect - cosmossdk.io/log v0.0.0-20230219145338-9553bf1eec78 // indirect cosmossdk.io/math v1.0.0-beta.6.0.20230216172121-959ce49135e4 // indirect cosmossdk.io/x/tx v0.2.0 // indirect filippo.io/edwards25519 v1.0.0 // indirect diff --git a/x/upgrade/keeper/keeper.go b/x/upgrade/keeper/keeper.go index ed3ccf1ccb2..f4ac2d612c0 100644 --- a/x/upgrade/keeper/keeper.go +++ b/x/upgrade/keeper/keeper.go @@ -9,9 +9,8 @@ import ( "path/filepath" "sort" - "github.com/cometbft/cometbft/libs/log" - errorsmod "cosmossdk.io/errors" + "cosmossdk.io/log" "cosmossdk.io/store/prefix" storetypes "cosmossdk.io/store/types" xp "cosmossdk.io/x/upgrade/exported" diff --git a/x/upgrade/keeper/keeper_test.go b/x/upgrade/keeper/keeper_test.go index 9eabd0920d9..eed7f80ab3e 100644 --- a/x/upgrade/keeper/keeper_test.go +++ b/x/upgrade/keeper/keeper_test.go @@ -5,10 +5,10 @@ import ( "testing" "time" - "github.com/cometbft/cometbft/libs/log" cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" "github.com/stretchr/testify/suite" + "cosmossdk.io/log" storetypes "cosmossdk.io/store/types" "cosmossdk.io/x/upgrade" "cosmossdk.io/x/upgrade/keeper" diff --git a/x/upgrade/types/plan_test.go b/x/upgrade/types/plan_test.go index 1801db97a81..4ef19b1ff0d 100644 --- a/x/upgrade/types/plan_test.go +++ b/x/upgrade/types/plan_test.go @@ -4,11 +4,11 @@ import ( "testing" "time" - "github.com/cometbft/cometbft/libs/log" cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" "github.com/stretchr/testify/assert" "github.com/stretchr/testify/require" + "cosmossdk.io/log" "cosmossdk.io/x/upgrade/types" codectypes "github.com/cosmos/cosmos-sdk/codec/types" diff --git a/x/upgrade/types/storeloader_test.go b/x/upgrade/types/storeloader_test.go index 9c7ef2e303e..16c27bd3c42 100644 --- a/x/upgrade/types/storeloader_test.go +++ b/x/upgrade/types/storeloader_test.go @@ -7,11 +7,11 @@ import ( "testing" abci "github.com/cometbft/cometbft/abci/types" - "github.com/cometbft/cometbft/libs/log" cmtproto "github.com/cometbft/cometbft/proto/tendermint/types" dbm "github.com/cosmos/cosmos-db" "github.com/stretchr/testify/require" + "cosmossdk.io/log" "cosmossdk.io/store/metrics" pruningtypes "cosmossdk.io/store/pruning/types" "cosmossdk.io/store/rootmulti" @@ -27,7 +27,7 @@ func useUpgradeLoader(height int64, upgrades *storetypes.StoreUpgrades) func(*ba } func defaultLogger() log.Logger { - return log.NewTMLogger(log.NewSyncWriter(os.Stdout)) + return log.NewLogger() } func initStore(t *testing.T, db dbm.DB, storeKey string, k, v []byte) {