From 46b65e228b55358a90b13e76e06525298e1cff1f Mon Sep 17 00:00:00 2001 From: Jared Wasinger Date: Wed, 8 Nov 2023 19:53:20 +0800 Subject: [PATCH] remove extra spaces. add test for nil big.Int/uint256.Int. move log.backtrace/log.debug flags to flags_legacy.go --- cmd/geth/main.go | 2 ++ cmd/utils/flags.go | 7 +++++++ cmd/utils/flags_legacy.go | 12 ++++++++++++ internal/debug/flags.go | 20 -------------------- log/handler.go | 8 ++++---- signer/core/auditlog.go | 1 - signer/storage/aes_gcm_storage_test.go | 1 - 7 files changed, 25 insertions(+), 26 deletions(-) diff --git a/cmd/geth/main.go b/cmd/geth/main.go index 2d4fe3dc06..ce40be3fd6 100644 --- a/cmd/geth/main.go +++ b/cmd/geth/main.go @@ -144,6 +144,8 @@ var ( utils.GpoMaxGasPriceFlag, utils.GpoIgnoreGasPriceFlag, configFileFlag, + utils.DebugFlag, + utils.BacktraceAtFlag, }, utils.NetworkFlags, utils.DatabaseFlags) rpcFlags = []cli.Flag{ diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 8bbacac51d..482dc886cb 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -1459,6 +1459,13 @@ func SetNodeConfig(ctx *cli.Context, cfg *node.Config) { log.Info(fmt.Sprintf("Using %s as db engine", dbEngine)) cfg.DBEngine = dbEngine } + // deprecation notice for log debug flags (TODO: find a more appropriate place to put these?) + if ctx.IsSet(BacktraceAtFlag.Name) { + log.Warn("log.backtrace flag is deprecated") + } + if ctx.IsSet(DebugFlag.Name) { + log.Warn("log.debug flag is deprecated") + } } func setSmartCard(ctx *cli.Context, cfg *node.Config) { diff --git a/cmd/utils/flags_legacy.go b/cmd/utils/flags_legacy.go index 6669ff176f..88a4bcd80f 100644 --- a/cmd/utils/flags_legacy.go +++ b/cmd/utils/flags_legacy.go @@ -77,6 +77,18 @@ var ( Value: ethconfig.Defaults.TransactionHistory, Category: flags.DeprecatedCategory, } + // Deprecated November 2023 + BacktraceAtFlag = &cli.StringFlag{ + Name: "log.backtrace", + Usage: "Request a stack trace at a specific logging statement (e.g. \"block.go:271\")", + Value: "", + Category: flags.LoggingCategory, + } + DebugFlag = &cli.BoolFlag{ + Name: "log.debug", + Usage: "Prepends log messages with call-site location (file and line number)", + Category: flags.LoggingCategory, + } ) // showDeprecated displays deprecated flags that will be soon removed from the codebase. diff --git a/internal/debug/flags.go b/internal/debug/flags.go index 063743f2bd..a7c87a930a 100644 --- a/internal/debug/flags.go +++ b/internal/debug/flags.go @@ -76,17 +76,6 @@ var ( Usage: "Write logs to a file", Category: flags.LoggingCategory, } - backtraceAtFlag = &cli.StringFlag{ - Name: "log.backtrace", - Usage: "Request a stack trace at a specific logging statement (e.g. \"block.go:271\")", - Value: "", - Category: flags.LoggingCategory, - } - debugFlag = &cli.BoolFlag{ - Name: "log.debug", - Usage: "Prepends log messages with call-site location (file and line number)", - Category: flags.LoggingCategory, - } logRotateFlag = &cli.BoolFlag{ Name: "log.rotate", Usage: "Enables log file rotation", @@ -160,8 +149,6 @@ var ( var Flags = []cli.Flag{ verbosityFlag, logVmoduleFlag, - backtraceAtFlag, - debugFlag, vmoduleFlag, logjsonFlag, logFormatFlag, @@ -283,13 +270,6 @@ func Setup(ctx *cli.Context) error { } glogger.Vmodule(vmodule) - if ctx.IsSet(backtraceAtFlag.Name) { - defer log.Warn("The flag '--log.backtraceat' is depcrecated and should no longer be used.") - } - if ctx.IsSet(debugFlag.Name) { - defer log.Warn("The flag '--log.debug' is depcrecated and should no longer be used.") - } - log.SetDefault(log.NewLogger(glogger)) // profiling, tracing diff --git a/log/handler.go b/log/handler.go index 655e33c114..060009559c 100644 --- a/log/handler.go +++ b/log/handler.go @@ -275,15 +275,15 @@ func builtinReplace(_ []string, attr slog.Attr) slog.Attr { attr = slog.Any(attr.Key, v.Format(timeFormat)) case *big.Int: if v == nil { - attr.Value = slog.AnyValue("") + attr.Value = slog.StringValue("") } else { - attr.Value = slog.AnyValue(v.String()) + attr.Value = slog.StringValue(v.String()) } case *uint256.Int: if v == nil { - attr.Value = slog.AnyValue("") + attr.Value = slog.StringValue("") } else { - attr.Value = slog.AnyValue(v.ToBig().String()) + attr.Value = slog.StringValue(v.Dec()) } } return attr diff --git a/signer/core/auditlog.go b/signer/core/auditlog.go index bd8839371d..324f097033 100644 --- a/signer/core/auditlog.go +++ b/signer/core/auditlog.go @@ -22,7 +22,6 @@ import ( "os" "golang.org/x/exp/slog" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common/hexutil" "github.com/ethereum/go-ethereum/internal/ethapi" diff --git a/signer/storage/aes_gcm_storage_test.go b/signer/storage/aes_gcm_storage_test.go index b3102e3cda..9b3a17fce6 100644 --- a/signer/storage/aes_gcm_storage_test.go +++ b/signer/storage/aes_gcm_storage_test.go @@ -24,7 +24,6 @@ import ( "testing" "golang.org/x/exp/slog" - "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/log" "github.com/mattn/go-colorable"