From 0f3f2aa4bc54c6c6c2ed6d4f859bb0e60467cc94 Mon Sep 17 00:00:00 2001 From: Sam Kleinman Date: Mon, 10 Jan 2022 13:56:42 -0500 Subject: [PATCH] log: remove support for traces (#7542) --- abci/cmd/abci-cli/abci-cli.go | 4 ++-- cmd/priv_val_server/main.go | 2 +- cmd/tendermint/commands/debug/debug.go | 2 +- cmd/tendermint/commands/light.go | 2 +- cmd/tendermint/commands/root.go | 4 ++-- libs/log/default.go | 13 +++---------- libs/log/default_test.go | 4 ++-- libs/log/nop.go | 1 - libs/log/testing.go | 7 +------ light/example_test.go | 2 +- rpc/jsonrpc/jsonrpc_test.go | 2 +- rpc/jsonrpc/test/main.go | 2 +- rpc/test/helpers.go | 2 +- test/e2e/app/app.go | 2 +- test/e2e/generator/main.go | 2 +- test/e2e/node/main.go | 4 ++-- test/e2e/runner/main.go | 2 +- test/fuzz/rpc/jsonrpc/server/handler.go | 2 +- 18 files changed, 23 insertions(+), 36 deletions(-) diff --git a/abci/cmd/abci-cli/abci-cli.go b/abci/cmd/abci-cli/abci-cli.go index 783c41dbb..512f4e772 100644 --- a/abci/cmd/abci-cli/abci-cli.go +++ b/abci/cmd/abci-cli/abci-cli.go @@ -60,7 +60,7 @@ var RootCmd = &cobra.Command{ } if logger == nil { - logger = log.MustNewDefaultLogger(log.LogFormatPlain, log.LogLevelInfo, false) + logger = log.MustNewDefaultLogger(log.LogFormatPlain, log.LogLevelInfo) } if client == nil { @@ -575,7 +575,7 @@ func cmdQuery(cmd *cobra.Command, args []string) error { } func cmdKVStore(cmd *cobra.Command, args []string) error { - logger := log.MustNewDefaultLogger(log.LogFormatPlain, log.LogLevelInfo, false) + logger := log.MustNewDefaultLogger(log.LogFormatPlain, log.LogLevelInfo) // Create the application - in memory or persisted to disk var app types.Application diff --git a/cmd/priv_val_server/main.go b/cmd/priv_val_server/main.go index 0708edd5c..baacadf1e 100644 --- a/cmd/priv_val_server/main.go +++ b/cmd/priv_val_server/main.go @@ -46,7 +46,7 @@ func main() { rootCA = flag.String("rootcafile", "", "absolute path to root CA") prometheusAddr = flag.String("prometheus-addr", "", "address for prometheus endpoint (host:port)") - logger = log.MustNewDefaultLogger(log.LogFormatPlain, log.LogLevelInfo, false). + logger = log.MustNewDefaultLogger(log.LogFormatPlain, log.LogLevelInfo). With("module", "priv_val") ) flag.Parse() diff --git a/cmd/tendermint/commands/debug/debug.go b/cmd/tendermint/commands/debug/debug.go index e07f7978d..2bf76babc 100644 --- a/cmd/tendermint/commands/debug/debug.go +++ b/cmd/tendermint/commands/debug/debug.go @@ -15,7 +15,7 @@ var ( flagProfAddr = "pprof-laddr" flagFrequency = "frequency" - logger = log.MustNewDefaultLogger(log.LogFormatPlain, log.LogLevelInfo, false) + logger = log.MustNewDefaultLogger(log.LogFormatPlain, log.LogLevelInfo) ) // DebugCmd defines the root command containing subcommands that assist in diff --git a/cmd/tendermint/commands/light.go b/cmd/tendermint/commands/light.go index 31171174d..9cad3397f 100644 --- a/cmd/tendermint/commands/light.go +++ b/cmd/tendermint/commands/light.go @@ -102,7 +102,7 @@ func init() { } func runProxy(cmd *cobra.Command, args []string) error { - logger, err := log.NewDefaultLogger(logFormat, logLevel, false) + logger, err := log.NewDefaultLogger(logFormat, logLevel) if err != nil { return err } diff --git a/cmd/tendermint/commands/root.go b/cmd/tendermint/commands/root.go index 9e1333885..354b414bf 100644 --- a/cmd/tendermint/commands/root.go +++ b/cmd/tendermint/commands/root.go @@ -13,7 +13,7 @@ import ( var ( config = cfg.DefaultConfig() - logger = log.MustNewDefaultLogger(log.LogFormatPlain, log.LogLevelInfo, false) + logger = log.MustNewDefaultLogger(log.LogFormatPlain, log.LogLevelInfo) ctxTimeout = 4 * time.Second ) @@ -55,7 +55,7 @@ var RootCmd = &cobra.Command{ return err } - logger, err = log.NewDefaultLogger(config.LogFormat, config.LogLevel, false) + logger, err = log.NewDefaultLogger(config.LogFormat, config.LogLevel) if err != nil { return err } diff --git a/libs/log/default.go b/libs/log/default.go index ca48fcd72..47800a3d9 100644 --- a/libs/log/default.go +++ b/libs/log/default.go @@ -14,8 +14,6 @@ var _ Logger = (*defaultLogger)(nil) type defaultLogger struct { zerolog.Logger - - trace bool } // NewDefaultLogger returns a default logger that can be used within Tendermint @@ -26,7 +24,7 @@ type defaultLogger struct { // Since zerolog supports typed structured logging and it is difficult to reflect // that in a generic interface, all logging methods accept a series of key/value // pair tuples, where the key must be a string. -func NewDefaultLogger(format, level string, trace bool) (Logger, error) { +func NewDefaultLogger(format, level string) (Logger, error) { var logWriter io.Writer switch strings.ToLower(format) { case LogFormatPlain, LogFormatText: @@ -59,14 +57,13 @@ func NewDefaultLogger(format, level string, trace bool) (Logger, error) { return defaultLogger{ Logger: zerolog.New(logWriter).Level(logLevel).With().Timestamp().Logger(), - trace: trace, }, nil } // MustNewDefaultLogger delegates a call NewDefaultLogger where it panics on // error. -func MustNewDefaultLogger(format, level string, trace bool) Logger { - logger, err := NewDefaultLogger(format, level, trace) +func MustNewDefaultLogger(format, level string) Logger { + logger, err := NewDefaultLogger(format, level) if err != nil { panic(err) } @@ -80,9 +77,6 @@ func (l defaultLogger) Info(msg string, keyVals ...interface{}) { func (l defaultLogger) Error(msg string, keyVals ...interface{}) { e := l.Logger.Error() - if l.trace { - e = e.Stack() - } e.Fields(getLogFields(keyVals...)).Msg(msg) } @@ -94,7 +88,6 @@ func (l defaultLogger) Debug(msg string, keyVals ...interface{}) { func (l defaultLogger) With(keyVals ...interface{}) Logger { return defaultLogger{ Logger: l.Logger.With().Fields(getLogFields(keyVals...)).Logger(), - trace: l.trace, } } diff --git a/libs/log/default_test.go b/libs/log/default_test.go index c66508f04..ca854c7ad 100644 --- a/libs/log/default_test.go +++ b/libs/log/default_test.go @@ -34,11 +34,11 @@ func TestNewDefaultLogger(t *testing.T) { tc := tc t.Run(name, func(t *testing.T) { - _, err := log.NewDefaultLogger(tc.format, tc.level, false) + _, err := log.NewDefaultLogger(tc.format, tc.level) if tc.expectErr { require.Error(t, err) require.Panics(t, func() { - _ = log.MustNewDefaultLogger(tc.format, tc.level, false) + _ = log.MustNewDefaultLogger(tc.format, tc.level) }) } else { require.NoError(t, err) diff --git a/libs/log/nop.go b/libs/log/nop.go index 4b3bfb196..e49540c10 100644 --- a/libs/log/nop.go +++ b/libs/log/nop.go @@ -7,6 +7,5 @@ import ( func NewNopLogger() Logger { return defaultLogger{ Logger: zerolog.Nop(), - trace: false, } } diff --git a/libs/log/testing.go b/libs/log/testing.go index b76bb77c6..92b84c742 100644 --- a/libs/log/testing.go +++ b/libs/log/testing.go @@ -32,7 +32,7 @@ func TestingLogger() Logger { } if testing.Verbose() { - testingLogger = MustNewDefaultLogger(LogFormatText, LogLevelDebug, true) + testingLogger = MustNewDefaultLogger(LogFormatText, LogLevelDebug) } else { testingLogger = NewNopLogger() } @@ -73,13 +73,8 @@ func NewTestingLoggerWithLevel(t testing.TB, level string) Logger { if err != nil { t.Fatalf("failed to parse log level (%s): %v", level, err) } - trace := false - if testing.Verbose() { - trace = true - } return defaultLogger{ Logger: zerolog.New(newSyncWriter(testingWriter{t})).Level(logLevel), - trace: trace, } } diff --git a/light/example_test.go b/light/example_test.go index c2dfc7fb0..d22525b30 100644 --- a/light/example_test.go +++ b/light/example_test.go @@ -26,7 +26,7 @@ func ExampleClient() { stdlog.Fatal(err) } - logger, err := log.NewDefaultLogger(log.LogFormatPlain, log.LogLevelInfo, false) + logger, err := log.NewDefaultLogger(log.LogFormatPlain, log.LogLevelInfo) if err != nil { stdlog.Fatal(err) } diff --git a/rpc/jsonrpc/jsonrpc_test.go b/rpc/jsonrpc/jsonrpc_test.go index 916f85ca1..e43e14d42 100644 --- a/rpc/jsonrpc/jsonrpc_test.go +++ b/rpc/jsonrpc/jsonrpc_test.go @@ -94,7 +94,7 @@ func TestMain(m *testing.M) { // launch unix and tcp servers func setup(ctx context.Context) error { - logger := log.MustNewDefaultLogger(log.LogFormatPlain, log.LogLevelInfo, false) + logger := log.MustNewDefaultLogger(log.LogFormatPlain, log.LogLevelInfo) cmd := exec.Command("rm", "-f", unixSocket) err := cmd.Start() diff --git a/rpc/jsonrpc/test/main.go b/rpc/jsonrpc/test/main.go index f11709f98..4517f0298 100644 --- a/rpc/jsonrpc/test/main.go +++ b/rpc/jsonrpc/test/main.go @@ -28,7 +28,7 @@ type Result struct { func main() { var ( mux = http.NewServeMux() - logger = log.MustNewDefaultLogger(log.LogFormatPlain, log.LogLevelInfo, false) + logger = log.MustNewDefaultLogger(log.LogFormatPlain, log.LogLevelInfo) ) ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM) diff --git a/rpc/test/helpers.go b/rpc/test/helpers.go index 90c3b2e49..b7db50f6c 100644 --- a/rpc/test/helpers.go +++ b/rpc/test/helpers.go @@ -89,7 +89,7 @@ func StartTendermint( if nodeOpts.suppressStdout { logger = log.NewNopLogger() } else { - logger = log.MustNewDefaultLogger(log.LogFormatPlain, log.LogLevelInfo, false) + logger = log.MustNewDefaultLogger(log.LogFormatPlain, log.LogLevelInfo) } papp := abciclient.NewLocalCreator(app) tmNode, err := node.New(ctx, conf, logger, papp, nil) diff --git a/test/e2e/app/app.go b/test/e2e/app/app.go index 5a782fa33..f2bff3713 100644 --- a/test/e2e/app/app.go +++ b/test/e2e/app/app.go @@ -89,7 +89,7 @@ func NewApplication(cfg *Config) (*Application, error) { return nil, err } return &Application{ - logger: log.MustNewDefaultLogger(log.LogFormatPlain, log.LogLevelInfo, false), + logger: log.MustNewDefaultLogger(log.LogFormatPlain, log.LogLevelInfo), state: state, snapshots: snapshots, cfg: cfg, diff --git a/test/e2e/generator/main.go b/test/e2e/generator/main.go index 38f36d0da..10b809279 100644 --- a/test/e2e/generator/main.go +++ b/test/e2e/generator/main.go @@ -17,7 +17,7 @@ const ( randomSeed int64 = 4827085738 ) -var logger = log.MustNewDefaultLogger(log.LogFormatPlain, log.LogLevelInfo, false) +var logger = log.MustNewDefaultLogger(log.LogFormatPlain, log.LogLevelInfo) func main() { NewCLI().Run() diff --git a/test/e2e/node/main.go b/test/e2e/node/main.go index 2509c9767..5a60a20bd 100644 --- a/test/e2e/node/main.go +++ b/test/e2e/node/main.go @@ -34,7 +34,7 @@ import ( e2e "github.com/tendermint/tendermint/test/e2e/pkg" ) -var logger = log.MustNewDefaultLogger(log.LogFormatPlain, log.LogLevelInfo, false) +var logger = log.MustNewDefaultLogger(log.LogFormatPlain, log.LogLevelInfo) // main is the binary entrypoint. func main() { @@ -297,7 +297,7 @@ func setupNode() (*config.Config, log.Logger, error) { return nil, nil, fmt.Errorf("error in config file: %w", err) } - nodeLogger, err := log.NewDefaultLogger(tmcfg.LogFormat, tmcfg.LogLevel, false) + nodeLogger, err := log.NewDefaultLogger(tmcfg.LogFormat, tmcfg.LogLevel) if err != nil { return nil, nil, err } diff --git a/test/e2e/runner/main.go b/test/e2e/runner/main.go index c163c5e96..83d1327be 100644 --- a/test/e2e/runner/main.go +++ b/test/e2e/runner/main.go @@ -16,7 +16,7 @@ import ( const randomSeed = 2308084734268 -var logger = log.MustNewDefaultLogger(log.LogFormatPlain, log.LogLevelInfo, false) +var logger = log.MustNewDefaultLogger(log.LogFormatPlain, log.LogLevelInfo) func main() { NewCLI().Run() diff --git a/test/fuzz/rpc/jsonrpc/server/handler.go b/test/fuzz/rpc/jsonrpc/server/handler.go index 723c0e030..61779b7f4 100644 --- a/test/fuzz/rpc/jsonrpc/server/handler.go +++ b/test/fuzz/rpc/jsonrpc/server/handler.go @@ -19,7 +19,7 @@ var mux *http.ServeMux func init() { mux = http.NewServeMux() - lgr := log.MustNewDefaultLogger(log.LogFormatPlain, log.LogLevelInfo, false) + lgr := log.MustNewDefaultLogger(log.LogFormatPlain, log.LogLevelInfo) rs.RegisterRPCFuncs(mux, rpcFuncMap, lgr) }