Skip to content

Commit

Permalink
all: replace log15 with slog (ethereum#28187)
Browse files Browse the repository at this point in the history
  • Loading branch information
gzliudan committed Nov 15, 2024
1 parent d60d85a commit 16f9644
Show file tree
Hide file tree
Showing 34 changed files with 999 additions and 1,711 deletions.
8 changes: 3 additions & 5 deletions cmd/XDC/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ import (
"github.com/XinFinOrg/XDPoSChain/cmd/utils"
"github.com/XinFinOrg/XDPoSChain/common"
"github.com/XinFinOrg/XDPoSChain/eth/ethconfig"
"github.com/XinFinOrg/XDPoSChain/internal/debug"
"github.com/XinFinOrg/XDPoSChain/log"
"github.com/XinFinOrg/XDPoSChain/node"
"github.com/XinFinOrg/XDPoSChain/params"
"github.com/naoina/toml"
Expand Down Expand Up @@ -143,9 +141,9 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, XDCConfig) {
if ctx.GlobalIsSet(utils.StakingEnabledFlag.Name) {
cfg.StakeEnable = ctx.GlobalBool(utils.StakingEnabledFlag.Name)
}
if !ctx.GlobalIsSet(debug.VerbosityFlag.Name) {
debug.Glogger.Verbosity(log.Lvl(cfg.Verbosity))
}
// if !ctx.GlobalIsSet(debug.VerbosityFlag.Name) {
// debug.Verbosity(log.Lvl(cfg.Verbosity))
// }

if !ctx.GlobalIsSet(utils.NATFlag.Name) && cfg.NAT != "" {
ctx.Set(utils.NATFlag.Name, cfg.NAT)
Expand Down
2 changes: 2 additions & 0 deletions cmd/XDC/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,8 @@ var (
utils.GpoIgnoreGasPriceFlag,
//utils.ExtraDataFlag,
configFileFlag,
utils.LogDebugFlag,
utils.LogBacktraceAtFlag,
utils.AnnounceTxsFlag,
utils.StoreRewardFlag,
utils.RollbackFlag,
Expand Down
6 changes: 3 additions & 3 deletions cmd/bootnode/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,10 +51,10 @@ func main() {
)
flag.Parse()

glogger := log.NewGlogHandler(log.StreamHandler(os.Stderr, log.TerminalFormat(false)))
glogger.Verbosity(log.Lvl(*verbosity))
glogger := log.NewGlogHandler(log.NewTerminalHandler(os.Stderr, false))
glogger.Verbosity(log.FromLegacyLevel(*verbosity))
glogger.Vmodule(*vmodule)
log.Root().SetHandler(glogger)
log.SetDefault(log.NewLogger(glogger))

natm, err := nat.Parse(*natdesc)
if err != nil {
Expand Down
8 changes: 8 additions & 0 deletions cmd/evm/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,14 @@ var (
Name: "nostack",
Usage: "disable stack output",
}
DisableStorageFlag = &cli.BoolFlag{
Name: "nostorage",
Usage: "disable storage output",
}
DisableReturnDataFlag = &cli.BoolFlag{
Name: "noreturndata",
Usage: "enable return data output",
}
)

func init() {
Expand Down
18 changes: 8 additions & 10 deletions cmd/evm/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,21 +22,18 @@ import (
"fmt"
"io"
"os"
goruntime "runtime"
"runtime/pprof"
"time"

"github.com/XinFinOrg/XDPoSChain/core/rawdb"

goruntime "runtime"

"github.com/XinFinOrg/XDPoSChain/cmd/evm/internal/compiler"
"github.com/XinFinOrg/XDPoSChain/cmd/utils"
"github.com/XinFinOrg/XDPoSChain/common"
"github.com/XinFinOrg/XDPoSChain/core"
"github.com/XinFinOrg/XDPoSChain/core/rawdb"
"github.com/XinFinOrg/XDPoSChain/core/state"
"github.com/XinFinOrg/XDPoSChain/core/vm"
"github.com/XinFinOrg/XDPoSChain/core/vm/runtime"
"github.com/XinFinOrg/XDPoSChain/log"
"github.com/XinFinOrg/XDPoSChain/params"
cli "gopkg.in/urfave/cli.v1"
)
Expand Down Expand Up @@ -71,12 +68,12 @@ func readGenesis(genesisPath string) *core.Genesis {
}

func runCmd(ctx *cli.Context) error {
glogger := log.NewGlogHandler(log.StreamHandler(os.Stderr, log.TerminalFormat(false)))
glogger.Verbosity(log.Lvl(ctx.GlobalInt(VerbosityFlag.Name)))
log.Root().SetHandler(glogger)
logconfig := &vm.LogConfig{
EnableMemory: !ctx.GlobalBool(DisableMemoryFlag.Name),
DisableStack: ctx.GlobalBool(DisableStackFlag.Name),
EnableMemory: !ctx.GlobalBool(DisableMemoryFlag.Name),
DisableStack: ctx.GlobalBool(DisableStackFlag.Name),
DisableStorage: ctx.Bool(DisableStorageFlag.Name),
EnableReturnData: !ctx.Bool(DisableReturnDataFlag.Name),
Debug: ctx.Bool(DebugFlag.Name),
}

var (
Expand All @@ -95,6 +92,7 @@ func runCmd(ctx *cli.Context) error {
} else {
debugLogger = vm.NewStructLogger(logconfig)
}

if ctx.GlobalString(GenesisFlag.Name) != "" {
gen := readGenesis(ctx.GlobalString(GenesisFlag.Name))
db := rawdb.NewMemoryDatabase()
Expand Down
13 changes: 5 additions & 8 deletions cmd/evm/staterunner.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,7 @@ import (

"github.com/XinFinOrg/XDPoSChain/core/state"
"github.com/XinFinOrg/XDPoSChain/core/vm"
"github.com/XinFinOrg/XDPoSChain/log"
"github.com/XinFinOrg/XDPoSChain/tests"

cli "gopkg.in/urfave/cli.v1"
)

Expand All @@ -49,16 +47,15 @@ func stateTestCmd(ctx *cli.Context) error {
if len(ctx.Args().First()) == 0 {
return errors.New("path-to-test argument required")
}
// Configure the go-ethereum logger
glogger := log.NewGlogHandler(log.StreamHandler(os.Stderr, log.TerminalFormat(false)))
glogger.Verbosity(log.Lvl(ctx.GlobalInt(VerbosityFlag.Name)))
log.Root().SetHandler(glogger)

// Configure the EVM logger
config := &vm.LogConfig{
EnableMemory: !ctx.GlobalBool(DisableMemoryFlag.Name),
DisableStack: ctx.GlobalBool(DisableStackFlag.Name),
EnableMemory: !ctx.GlobalBool(DisableMemoryFlag.Name),
DisableStack: ctx.GlobalBool(DisableStackFlag.Name),
DisableStorage: ctx.Bool(DisableStorageFlag.Name),
EnableReturnData: !ctx.Bool(DisableReturnDataFlag.Name),
}

var (
tracer vm.EVMLogger
debugger *vm.StructLogger
Expand Down
2 changes: 1 addition & 1 deletion cmd/faucet/faucet.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ var (
func main() {
// Parse the flags and set up the logger to print everything requested
flag.Parse()
log.Root().SetHandler(log.LvlFilterHandler(log.Lvl(*logFlag), log.StreamHandler(os.Stderr, log.TerminalFormat(true))))
log.SetDefault(log.NewLogger(log.NewTerminalHandlerWithLevel(os.Stderr, log.FromLegacyLevel(*logFlag), true)))

// Construct the payout tiers
amounts := make([]string, *tiersFlag)
Expand Down
2 changes: 1 addition & 1 deletion cmd/puppeth/puppeth.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ func main() {
}
app.Action = func(c *cli.Context) error {
// Set up the logger to print everything and the random generator
log.Root().SetHandler(log.LvlFilterHandler(log.Lvl(c.Int("loglevel")), log.StreamHandler(os.Stdout, log.TerminalFormat(true))))
log.SetDefault(log.NewLogger(log.NewTerminalHandlerWithLevel(os.Stdout, log.FromLegacyLevel(c.Int("loglevel")), true)))
rand.Seed(time.Now().UnixNano())

network := c.String("network")
Expand Down
17 changes: 17 additions & 0 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -618,6 +618,16 @@ var (
Name: "slave",
Usage: "Enable slave mode",
}
// Deprecated November 2023
LogBacktraceAtFlag = &cli.StringFlag{
Name: "log-backtrace",
Usage: "Request a stack trace at a specific logging statement (deprecated)",
Value: "",
}
LogDebugFlag = &cli.BoolFlag{
Name: "log-debug",
Usage: "Prepends log messages with call-site location (deprecated)",
}
)

// MakeDataDir retrieves the currently requested data directory, terminating
Expand Down Expand Up @@ -1015,6 +1025,13 @@ func SetNodeConfig(ctx *cli.Context, cfg *node.Config) {
if ctx.GlobalIsSet(AnnounceTxsFlag.Name) {
cfg.AnnounceTxs = ctx.GlobalBool(AnnounceTxsFlag.Name)
}
// deprecation notice for log debug flags (TODO: find a more appropriate place to put these?)
if ctx.IsSet(LogBacktraceAtFlag.Name) {
log.Warn("log.backtrace flag is deprecated")
}
if ctx.IsSet(LogDebugFlag.Name) {
log.Warn("log.debug flag is deprecated")
}
}

func setGPO(ctx *cli.Context, cfg *gasprice.Config, light bool) {
Expand Down
7 changes: 4 additions & 3 deletions contracts/tests/Inherited_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ var (
)

func TestPriceFeed(t *testing.T) {
glogger := log.NewGlogHandler(log.StreamHandler(os.Stderr, log.TerminalFormat(false)))
glogger.Verbosity(log.LvlTrace)
log.Root().SetHandler(glogger)
glogger := log.NewGlogHandler(log.NewTerminalHandler(os.Stderr, false))
glogger.Verbosity(log.LevelTrace)
log.SetDefault(log.NewLogger(glogger))

common.TIPXDCXCancellationFee = big.NewInt(0)
// init genesis
contractBackend := backends.NewSimulatedBackend(core.GenesisAlloc{
Expand Down
2 changes: 1 addition & 1 deletion eth/protocol_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import (
)

func init() {
// log.Root().SetHandler(log.LvlFilterHandler(log.LvlTrace, log.StreamHandler(os.Stderr, log.TerminalFormat(false))))
// log.SetDefault(log.NewLogger(log.NewTerminalHandlerWithLevel(os.Stderr, log.LevelTrace, false)))
}

var testAccount, _ = crypto.HexToECDSA("b71c71a67e1177ad4e901695e1b4b9ee17ae16c6668d313eac2f96dbcda3f291")
Expand Down
27 changes: 9 additions & 18 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ module github.com/XinFinOrg/XDPoSChain
go 1.21

require (
bazil.org/fuse v0.0.0-20180421153158-65cc252bf669
github.com/VictoriaMetrics/fastcache v1.12.2
github.com/aristanetworks/goarista v0.0.0-20231019142648-8c6f0862ab98
github.com/btcsuite/btcd v0.0.0-20171128150713-2e60448ffcc6
Expand All @@ -12,9 +11,7 @@ require (
github.com/docker/docker v1.4.2-0.20180625184442-8e610b2b55bf
github.com/edsrzf/mmap-go v1.0.0
github.com/fatih/color v1.13.0
github.com/gizak/termui v2.2.0+incompatible
github.com/globalsign/mgo v0.0.0-20181015135952-eeefdecb41b8
github.com/go-stack/stack v1.8.1
github.com/golang/protobuf v1.5.3
github.com/golang/snappy v0.0.5-0.20220116011046-fa5810519dcb
github.com/gorilla/websocket v1.4.2
Expand All @@ -38,7 +35,6 @@ require (
github.com/stretchr/testify v1.8.4
github.com/syndtr/goleveldb v1.0.1-0.20210819022825-2ae1ddf74ef7
golang.org/x/crypto v0.15.0
golang.org/x/net v0.17.0
golang.org/x/sync v0.4.0
golang.org/x/sys v0.24.0
golang.org/x/tools v0.14.0
Expand All @@ -48,37 +44,32 @@ require (
gopkg.in/urfave/cli.v1 v1.20.0
)

require github.com/deckarep/golang-set v1.8.0
require (
github.com/deckarep/golang-set v1.8.0
github.com/dop251/goja v0.0.0-20200106141417-aaec0e7bde29
github.com/kylelemons/godebug v1.1.0
github.com/mattn/go-isatty v0.0.17
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible
golang.org/x/exp v0.0.0-20231006140011-7918f672742d
gopkg.in/natefinch/lumberjack.v2 v2.2.1
)

require (
github.com/StackExchange/wmi v1.2.1 // indirect
github.com/cespare/xxhash/v2 v2.3.0 // indirect
github.com/dlclark/regexp2 v1.10.0 // indirect
github.com/dop251/goja v0.0.0-20200106141417-aaec0e7bde29 // indirect
github.com/elastic/gosigar v0.8.1-0.20180330100440-37f05ff46ffa // indirect
github.com/go-ole/go-ole v1.2.5 // indirect
github.com/go-sourcemap/sourcemap v2.1.3+incompatible // indirect
github.com/google/go-cmp v0.6.0 // indirect
github.com/google/pprof v0.0.0-20230207041349-798e818bf904 // indirect
github.com/google/uuid v1.3.0 // indirect
github.com/kr/pretty v0.3.1 // indirect
github.com/kr/text v0.2.0 // indirect
github.com/kylelemons/godebug v1.1.0 // indirect
github.com/maruel/panicparse v0.0.0-20160720141634-ad661195ed0e // indirect
github.com/maruel/ut v1.0.2 // indirect
github.com/mattn/go-isatty v0.0.17 // indirect
github.com/mattn/go-runewidth v0.0.13 // indirect
github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7 // indirect
github.com/naoina/go-stringutil v0.1.0 // indirect
github.com/nsf/termbox-go v0.0.0-20170211012700-3540b76b9c77 // indirect
github.com/pmezard/go-difflib v1.0.0 // indirect
github.com/rivo/uniseg v0.2.0 // indirect
github.com/rogpeppe/go-internal v1.9.0 // indirect
github.com/shirou/gopsutil v3.21.4-0.20210419000835-c7a38de76ee5+incompatible // indirect
github.com/steakknife/hamming v0.0.0-20180906055917-c99c65617cd3 // indirect
github.com/tklauser/go-sysconf v0.3.12 // indirect
github.com/tklauser/numcpus v0.6.1 // indirect
golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect
golang.org/x/mod v0.13.0 // indirect
golang.org/x/term v0.14.0 // indirect
golang.org/x/text v0.14.0 // indirect
Expand Down
Loading

0 comments on commit 16f9644

Please sign in to comment.