Skip to content

Commit 77b0c0b

Browse files
authored
Merge pull request #734 from gzliudan/upgrade-log
upgrade package log to 2024-11-04
2 parents 6459d0c + 5bfaf06 commit 77b0c0b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+1531
-1931
lines changed

accounts/url.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@ func (u URL) String() string {
6464
func (u URL) TerminalString() string {
6565
url := u.String()
6666
if len(url) > 32 {
67-
return url[:31] + ""
67+
return url[:31] + ".."
6868
}
6969
return url
7070
}
@@ -76,10 +76,9 @@ func (u URL) MarshalJSON() ([]byte, error) {
7676

7777
// Cmp compares x and y and returns:
7878
//
79-
// -1 if x < y
80-
// 0 if x == y
81-
// +1 if x > y
82-
//
79+
// -1 if x < y
80+
// 0 if x == y
81+
// +1 if x > y
8382
func (u URL) Cmp(url URL) int {
8483
if u.Scheme == url.Scheme {
8584
return strings.Compare(u.Path, url.Path)

cmd/XDC/config.go

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,6 @@ import (
3333
"github.com/XinFinOrg/XDPoSChain/cmd/utils"
3434
"github.com/XinFinOrg/XDPoSChain/common"
3535
"github.com/XinFinOrg/XDPoSChain/eth/ethconfig"
36-
"github.com/XinFinOrg/XDPoSChain/internal/debug"
37-
"github.com/XinFinOrg/XDPoSChain/log"
3836
"github.com/XinFinOrg/XDPoSChain/node"
3937
"github.com/XinFinOrg/XDPoSChain/params"
4038
"github.com/naoina/toml"
@@ -143,9 +141,9 @@ func makeConfigNode(ctx *cli.Context) (*node.Node, XDCConfig) {
143141
if ctx.GlobalIsSet(utils.StakingEnabledFlag.Name) {
144142
cfg.StakeEnable = ctx.GlobalBool(utils.StakingEnabledFlag.Name)
145143
}
146-
if !ctx.GlobalIsSet(debug.VerbosityFlag.Name) {
147-
debug.Glogger.Verbosity(log.Lvl(cfg.Verbosity))
148-
}
144+
// if !ctx.GlobalIsSet(debug.VerbosityFlag.Name) {
145+
// debug.Verbosity(log.Lvl(cfg.Verbosity))
146+
// }
149147

150148
if !ctx.GlobalIsSet(utils.NATFlag.Name) && cfg.NAT != "" {
151149
ctx.Set(utils.NATFlag.Name, cfg.NAT)

cmd/XDC/main.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,8 @@ var (
136136
utils.GpoIgnoreGasPriceFlag,
137137
//utils.ExtraDataFlag,
138138
configFileFlag,
139+
utils.LogDebugFlag,
140+
utils.LogBacktraceAtFlag,
139141
utils.AnnounceTxsFlag,
140142
utils.StoreRewardFlag,
141143
utils.RollbackFlag,

cmd/bootnode/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,10 @@ func main() {
5151
)
5252
flag.Parse()
5353

54-
glogger := log.NewGlogHandler(log.StreamHandler(os.Stderr, log.TerminalFormat(false)))
55-
glogger.Verbosity(log.Lvl(*verbosity))
54+
glogger := log.NewGlogHandler(log.NewTerminalHandler(os.Stderr, false))
55+
glogger.Verbosity(log.FromLegacyLevel(*verbosity))
5656
glogger.Vmodule(*vmodule)
57-
log.Root().SetHandler(glogger)
57+
log.SetDefault(log.NewLogger(glogger))
5858

5959
natm, err := nat.Parse(*natdesc)
6060
if err != nil {

cmd/evm/main.go

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,14 @@ var (
110110
Name: "nostack",
111111
Usage: "disable stack output",
112112
}
113+
DisableStorageFlag = &cli.BoolFlag{
114+
Name: "nostorage",
115+
Usage: "disable storage output",
116+
}
117+
DisableReturnDataFlag = &cli.BoolFlag{
118+
Name: "noreturndata",
119+
Usage: "enable return data output",
120+
}
113121
)
114122

115123
func init() {

cmd/evm/runner.go

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,21 +22,18 @@ import (
2222
"fmt"
2323
"io"
2424
"os"
25+
goruntime "runtime"
2526
"runtime/pprof"
2627
"time"
2728

28-
"github.com/XinFinOrg/XDPoSChain/core/rawdb"
29-
30-
goruntime "runtime"
31-
3229
"github.com/XinFinOrg/XDPoSChain/cmd/evm/internal/compiler"
3330
"github.com/XinFinOrg/XDPoSChain/cmd/utils"
3431
"github.com/XinFinOrg/XDPoSChain/common"
3532
"github.com/XinFinOrg/XDPoSChain/core"
33+
"github.com/XinFinOrg/XDPoSChain/core/rawdb"
3634
"github.com/XinFinOrg/XDPoSChain/core/state"
3735
"github.com/XinFinOrg/XDPoSChain/core/vm"
3836
"github.com/XinFinOrg/XDPoSChain/core/vm/runtime"
39-
"github.com/XinFinOrg/XDPoSChain/log"
4037
"github.com/XinFinOrg/XDPoSChain/params"
4138
cli "gopkg.in/urfave/cli.v1"
4239
)
@@ -71,12 +68,12 @@ func readGenesis(genesisPath string) *core.Genesis {
7168
}
7269

7370
func runCmd(ctx *cli.Context) error {
74-
glogger := log.NewGlogHandler(log.StreamHandler(os.Stderr, log.TerminalFormat(false)))
75-
glogger.Verbosity(log.Lvl(ctx.GlobalInt(VerbosityFlag.Name)))
76-
log.Root().SetHandler(glogger)
7771
logconfig := &vm.LogConfig{
78-
EnableMemory: !ctx.GlobalBool(DisableMemoryFlag.Name),
79-
DisableStack: ctx.GlobalBool(DisableStackFlag.Name),
72+
EnableMemory: !ctx.GlobalBool(DisableMemoryFlag.Name),
73+
DisableStack: ctx.GlobalBool(DisableStackFlag.Name),
74+
DisableStorage: ctx.Bool(DisableStorageFlag.Name),
75+
EnableReturnData: !ctx.Bool(DisableReturnDataFlag.Name),
76+
Debug: ctx.Bool(DebugFlag.Name),
8077
}
8178

8279
var (
@@ -95,6 +92,7 @@ func runCmd(ctx *cli.Context) error {
9592
} else {
9693
debugLogger = vm.NewStructLogger(logconfig)
9794
}
95+
9896
if ctx.GlobalString(GenesisFlag.Name) != "" {
9997
gen := readGenesis(ctx.GlobalString(GenesisFlag.Name))
10098
db := rawdb.NewMemoryDatabase()

cmd/evm/staterunner.go

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,7 @@ import (
2424

2525
"github.com/XinFinOrg/XDPoSChain/core/state"
2626
"github.com/XinFinOrg/XDPoSChain/core/vm"
27-
"github.com/XinFinOrg/XDPoSChain/log"
2827
"github.com/XinFinOrg/XDPoSChain/tests"
29-
3028
cli "gopkg.in/urfave/cli.v1"
3129
)
3230

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

5751
// Configure the EVM logger
5852
config := &vm.LogConfig{
59-
EnableMemory: !ctx.GlobalBool(DisableMemoryFlag.Name),
60-
DisableStack: ctx.GlobalBool(DisableStackFlag.Name),
53+
EnableMemory: !ctx.GlobalBool(DisableMemoryFlag.Name),
54+
DisableStack: ctx.GlobalBool(DisableStackFlag.Name),
55+
DisableStorage: ctx.Bool(DisableStorageFlag.Name),
56+
EnableReturnData: !ctx.Bool(DisableReturnDataFlag.Name),
6157
}
58+
6259
var (
6360
tracer vm.EVMLogger
6461
debugger *vm.StructLogger

cmd/faucet/faucet.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ var (
9494
func main() {
9595
// Parse the flags and set up the logger to print everything requested
9696
flag.Parse()
97-
log.Root().SetHandler(log.LvlFilterHandler(log.Lvl(*logFlag), log.StreamHandler(os.Stderr, log.TerminalFormat(true))))
97+
log.SetDefault(log.NewLogger(log.NewTerminalHandlerWithLevel(os.Stderr, log.FromLegacyLevel(*logFlag), true)))
9898

9999
// Construct the payout tiers
100100
amounts := make([]string, *tiersFlag)

cmd/puppeth/puppeth.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ func main() {
4545
}
4646
app.Action = func(c *cli.Context) error {
4747
// Set up the logger to print everything and the random generator
48-
log.Root().SetHandler(log.LvlFilterHandler(log.Lvl(c.Int("loglevel")), log.StreamHandler(os.Stdout, log.TerminalFormat(true))))
48+
log.SetDefault(log.NewLogger(log.NewTerminalHandlerWithLevel(os.Stdout, log.FromLegacyLevel(c.Int("loglevel")), true)))
4949
rand.Seed(time.Now().UnixNano())
5050

5151
network := c.String("network")

cmd/utils/flags.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -618,6 +618,16 @@ var (
618618
Name: "slave",
619619
Usage: "Enable slave mode",
620620
}
621+
// Deprecated November 2023
622+
LogBacktraceAtFlag = &cli.StringFlag{
623+
Name: "log-backtrace",
624+
Usage: "Request a stack trace at a specific logging statement (deprecated)",
625+
Value: "",
626+
}
627+
LogDebugFlag = &cli.BoolFlag{
628+
Name: "log-debug",
629+
Usage: "Prepends log messages with call-site location (deprecated)",
630+
}
621631
)
622632

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

10201037
func setGPO(ctx *cli.Context, cfg *gasprice.Config, light bool) {

0 commit comments

Comments
 (0)