Browse Source

log: remove support for traces (#7542)

pull/7545/head
Sam Kleinman 3 years ago
committed by GitHub
parent
commit
0f3f2aa4bc
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
18 changed files with 23 additions and 36 deletions
  1. +2
    -2
      abci/cmd/abci-cli/abci-cli.go
  2. +1
    -1
      cmd/priv_val_server/main.go
  3. +1
    -1
      cmd/tendermint/commands/debug/debug.go
  4. +1
    -1
      cmd/tendermint/commands/light.go
  5. +2
    -2
      cmd/tendermint/commands/root.go
  6. +3
    -10
      libs/log/default.go
  7. +2
    -2
      libs/log/default_test.go
  8. +0
    -1
      libs/log/nop.go
  9. +1
    -6
      libs/log/testing.go
  10. +1
    -1
      light/example_test.go
  11. +1
    -1
      rpc/jsonrpc/jsonrpc_test.go
  12. +1
    -1
      rpc/jsonrpc/test/main.go
  13. +1
    -1
      rpc/test/helpers.go
  14. +1
    -1
      test/e2e/app/app.go
  15. +1
    -1
      test/e2e/generator/main.go
  16. +2
    -2
      test/e2e/node/main.go
  17. +1
    -1
      test/e2e/runner/main.go
  18. +1
    -1
      test/fuzz/rpc/jsonrpc/server/handler.go

+ 2
- 2
abci/cmd/abci-cli/abci-cli.go View File

@ -60,7 +60,7 @@ var RootCmd = &cobra.Command{
} }
if logger == nil { if logger == nil {
logger = log.MustNewDefaultLogger(log.LogFormatPlain, log.LogLevelInfo, false)
logger = log.MustNewDefaultLogger(log.LogFormatPlain, log.LogLevelInfo)
} }
if client == nil { if client == nil {
@ -575,7 +575,7 @@ func cmdQuery(cmd *cobra.Command, args []string) error {
} }
func cmdKVStore(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 // Create the application - in memory or persisted to disk
var app types.Application var app types.Application


+ 1
- 1
cmd/priv_val_server/main.go View File

@ -46,7 +46,7 @@ func main() {
rootCA = flag.String("rootcafile", "", "absolute path to root CA") rootCA = flag.String("rootcafile", "", "absolute path to root CA")
prometheusAddr = flag.String("prometheus-addr", "", "address for prometheus endpoint (host:port)") 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") With("module", "priv_val")
) )
flag.Parse() flag.Parse()


+ 1
- 1
cmd/tendermint/commands/debug/debug.go View File

@ -15,7 +15,7 @@ var (
flagProfAddr = "pprof-laddr" flagProfAddr = "pprof-laddr"
flagFrequency = "frequency" 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 // DebugCmd defines the root command containing subcommands that assist in


+ 1
- 1
cmd/tendermint/commands/light.go View File

@ -102,7 +102,7 @@ func init() {
} }
func runProxy(cmd *cobra.Command, args []string) error { func runProxy(cmd *cobra.Command, args []string) error {
logger, err := log.NewDefaultLogger(logFormat, logLevel, false)
logger, err := log.NewDefaultLogger(logFormat, logLevel)
if err != nil { if err != nil {
return err return err
} }


+ 2
- 2
cmd/tendermint/commands/root.go View File

@ -13,7 +13,7 @@ import (
var ( var (
config = cfg.DefaultConfig() config = cfg.DefaultConfig()
logger = log.MustNewDefaultLogger(log.LogFormatPlain, log.LogLevelInfo, false)
logger = log.MustNewDefaultLogger(log.LogFormatPlain, log.LogLevelInfo)
ctxTimeout = 4 * time.Second ctxTimeout = 4 * time.Second
) )
@ -55,7 +55,7 @@ var RootCmd = &cobra.Command{
return err return err
} }
logger, err = log.NewDefaultLogger(config.LogFormat, config.LogLevel, false)
logger, err = log.NewDefaultLogger(config.LogFormat, config.LogLevel)
if err != nil { if err != nil {
return err return err
} }


+ 3
- 10
libs/log/default.go View File

@ -14,8 +14,6 @@ var _ Logger = (*defaultLogger)(nil)
type defaultLogger struct { type defaultLogger struct {
zerolog.Logger zerolog.Logger
trace bool
} }
// NewDefaultLogger returns a default logger that can be used within Tendermint // 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 // 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 // that in a generic interface, all logging methods accept a series of key/value
// pair tuples, where the key must be a string. // 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 var logWriter io.Writer
switch strings.ToLower(format) { switch strings.ToLower(format) {
case LogFormatPlain, LogFormatText: case LogFormatPlain, LogFormatText:
@ -59,14 +57,13 @@ func NewDefaultLogger(format, level string, trace bool) (Logger, error) {
return defaultLogger{ return defaultLogger{
Logger: zerolog.New(logWriter).Level(logLevel).With().Timestamp().Logger(), Logger: zerolog.New(logWriter).Level(logLevel).With().Timestamp().Logger(),
trace: trace,
}, nil }, nil
} }
// MustNewDefaultLogger delegates a call NewDefaultLogger where it panics on // MustNewDefaultLogger delegates a call NewDefaultLogger where it panics on
// error. // 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 { if err != nil {
panic(err) panic(err)
} }
@ -80,9 +77,6 @@ func (l defaultLogger) Info(msg string, keyVals ...interface{}) {
func (l defaultLogger) Error(msg string, keyVals ...interface{}) { func (l defaultLogger) Error(msg string, keyVals ...interface{}) {
e := l.Logger.Error() e := l.Logger.Error()
if l.trace {
e = e.Stack()
}
e.Fields(getLogFields(keyVals...)).Msg(msg) 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 { func (l defaultLogger) With(keyVals ...interface{}) Logger {
return defaultLogger{ return defaultLogger{
Logger: l.Logger.With().Fields(getLogFields(keyVals...)).Logger(), Logger: l.Logger.With().Fields(getLogFields(keyVals...)).Logger(),
trace: l.trace,
} }
} }


+ 2
- 2
libs/log/default_test.go View File

@ -34,11 +34,11 @@ func TestNewDefaultLogger(t *testing.T) {
tc := tc tc := tc
t.Run(name, func(t *testing.T) { 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 { if tc.expectErr {
require.Error(t, err) require.Error(t, err)
require.Panics(t, func() { require.Panics(t, func() {
_ = log.MustNewDefaultLogger(tc.format, tc.level, false)
_ = log.MustNewDefaultLogger(tc.format, tc.level)
}) })
} else { } else {
require.NoError(t, err) require.NoError(t, err)


+ 0
- 1
libs/log/nop.go View File

@ -7,6 +7,5 @@ import (
func NewNopLogger() Logger { func NewNopLogger() Logger {
return defaultLogger{ return defaultLogger{
Logger: zerolog.Nop(), Logger: zerolog.Nop(),
trace: false,
} }
} }

+ 1
- 6
libs/log/testing.go View File

@ -32,7 +32,7 @@ func TestingLogger() Logger {
} }
if testing.Verbose() { if testing.Verbose() {
testingLogger = MustNewDefaultLogger(LogFormatText, LogLevelDebug, true)
testingLogger = MustNewDefaultLogger(LogFormatText, LogLevelDebug)
} else { } else {
testingLogger = NewNopLogger() testingLogger = NewNopLogger()
} }
@ -73,13 +73,8 @@ func NewTestingLoggerWithLevel(t testing.TB, level string) Logger {
if err != nil { if err != nil {
t.Fatalf("failed to parse log level (%s): %v", level, err) t.Fatalf("failed to parse log level (%s): %v", level, err)
} }
trace := false
if testing.Verbose() {
trace = true
}
return defaultLogger{ return defaultLogger{
Logger: zerolog.New(newSyncWriter(testingWriter{t})).Level(logLevel), Logger: zerolog.New(newSyncWriter(testingWriter{t})).Level(logLevel),
trace: trace,
} }
} }

+ 1
- 1
light/example_test.go View File

@ -26,7 +26,7 @@ func ExampleClient() {
stdlog.Fatal(err) stdlog.Fatal(err)
} }
logger, err := log.NewDefaultLogger(log.LogFormatPlain, log.LogLevelInfo, false)
logger, err := log.NewDefaultLogger(log.LogFormatPlain, log.LogLevelInfo)
if err != nil { if err != nil {
stdlog.Fatal(err) stdlog.Fatal(err)
} }


+ 1
- 1
rpc/jsonrpc/jsonrpc_test.go View File

@ -94,7 +94,7 @@ func TestMain(m *testing.M) {
// launch unix and tcp servers // launch unix and tcp servers
func setup(ctx context.Context) error { 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) cmd := exec.Command("rm", "-f", unixSocket)
err := cmd.Start() err := cmd.Start()


+ 1
- 1
rpc/jsonrpc/test/main.go View File

@ -28,7 +28,7 @@ type Result struct {
func main() { func main() {
var ( var (
mux = http.NewServeMux() 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) ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt, syscall.SIGTERM)


+ 1
- 1
rpc/test/helpers.go View File

@ -89,7 +89,7 @@ func StartTendermint(
if nodeOpts.suppressStdout { if nodeOpts.suppressStdout {
logger = log.NewNopLogger() logger = log.NewNopLogger()
} else { } else {
logger = log.MustNewDefaultLogger(log.LogFormatPlain, log.LogLevelInfo, false)
logger = log.MustNewDefaultLogger(log.LogFormatPlain, log.LogLevelInfo)
} }
papp := abciclient.NewLocalCreator(app) papp := abciclient.NewLocalCreator(app)
tmNode, err := node.New(ctx, conf, logger, papp, nil) tmNode, err := node.New(ctx, conf, logger, papp, nil)


+ 1
- 1
test/e2e/app/app.go View File

@ -89,7 +89,7 @@ func NewApplication(cfg *Config) (*Application, error) {
return nil, err return nil, err
} }
return &Application{ return &Application{
logger: log.MustNewDefaultLogger(log.LogFormatPlain, log.LogLevelInfo, false),
logger: log.MustNewDefaultLogger(log.LogFormatPlain, log.LogLevelInfo),
state: state, state: state,
snapshots: snapshots, snapshots: snapshots,
cfg: cfg, cfg: cfg,


+ 1
- 1
test/e2e/generator/main.go View File

@ -17,7 +17,7 @@ const (
randomSeed int64 = 4827085738 randomSeed int64 = 4827085738
) )
var logger = log.MustNewDefaultLogger(log.LogFormatPlain, log.LogLevelInfo, false)
var logger = log.MustNewDefaultLogger(log.LogFormatPlain, log.LogLevelInfo)
func main() { func main() {
NewCLI().Run() NewCLI().Run()


+ 2
- 2
test/e2e/node/main.go View File

@ -34,7 +34,7 @@ import (
e2e "github.com/tendermint/tendermint/test/e2e/pkg" 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. // main is the binary entrypoint.
func main() { func main() {
@ -297,7 +297,7 @@ func setupNode() (*config.Config, log.Logger, error) {
return nil, nil, fmt.Errorf("error in config file: %w", err) 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 { if err != nil {
return nil, nil, err return nil, nil, err
} }


+ 1
- 1
test/e2e/runner/main.go View File

@ -16,7 +16,7 @@ import (
const randomSeed = 2308084734268 const randomSeed = 2308084734268
var logger = log.MustNewDefaultLogger(log.LogFormatPlain, log.LogLevelInfo, false)
var logger = log.MustNewDefaultLogger(log.LogFormatPlain, log.LogLevelInfo)
func main() { func main() {
NewCLI().Run() NewCLI().Run()


+ 1
- 1
test/fuzz/rpc/jsonrpc/server/handler.go View File

@ -19,7 +19,7 @@ var mux *http.ServeMux
func init() { func init() {
mux = http.NewServeMux() mux = http.NewServeMux()
lgr := log.MustNewDefaultLogger(log.LogFormatPlain, log.LogLevelInfo, false)
lgr := log.MustNewDefaultLogger(log.LogFormatPlain, log.LogLevelInfo)
rs.RegisterRPCFuncs(mux, rpcFuncMap, lgr) rs.RegisterRPCFuncs(mux, rpcFuncMap, lgr)
} }


Loading…
Cancel
Save