Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions builder/files/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@

chain = "mainnet"
# chain = "mumbai"
# identity = "Pratiks-MacBook-Pro.local"
# log-level = "INFO"
# identity = "Annon-Identity"
# verbosity = 3
datadir = "/var/lib/bor/data"
# ancient = ""
# keystore = "/var/lib/bor/keystore"
Expand Down
4 changes: 3 additions & 1 deletion docs/cli/bootnode.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@

- ```v5```: Enable UDP v5 (default: false)

- ```log-level```: Log level (trace|debug|info|warn|error|crit) (default: info)
- ```verbosity```: Logging verbosity (5=trace|4=debug|3=info|2=warn|1=error|0=crit) (default: 3)

- ```log-level```: log level (trace|debug|info|warn|error|crit), will be deprecated soon. Use verbosity instead (default: info)

- ```nat```: port mapping mechanism (any|none|upnp|pmp|extip:<IP>) (default: none)

Expand Down
2 changes: 1 addition & 1 deletion docs/cli/example_config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

chain = "mainnet" # Name of the chain to sync ("mumbai", "mainnet") or path to a genesis file
identity = "Annon-Identity" # Name/Identity of the node (default = OS hostname)
log-level = "INFO" # Set log level for the server
verbosity = 3 # Logging verbosity for the server (5=trace|4=debug|3=info|2=warn|1=error|0=crit) (`log-level` was replaced by `verbosity`, and thus will be deprecated soon)
datadir = "var/lib/bor" # Path of the data directory to store information
ancient = "" # Data directory for ancient chain segments (default = inside chaindata)
keystore = "" # Path of the directory where keystores are located
Expand Down
8 changes: 7 additions & 1 deletion docs/cli/server.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,9 @@ The ```bor server``` command runs the Bor client.

- ```identity```: Name/Identity of the node

- ```log-level```: Set log level for the server (default: INFO)
- ```verbosity```: Logging verbosity for the server (5=trace|4=debug|3=info|2=warn|1=error|0=crit), default = 3 (default: 3)

- ```log-level```: Log level for the server (trace|debug|info|warn|error|crit), will be deprecated soon. Use verbosity instead

- ```datadir```: Path of the data directory to store information

Expand All @@ -34,6 +36,10 @@ The ```bor server``` command runs the Bor client.

- ```bor.heimdallgRPC```: Address of Heimdall gRPC service

- ```bor.runheimdall```: Run Heimdall service as a child process (default: false)

- ```bor.runheimdallargs```: Arguments to pass to Heimdall service

- ```ethstats```: Reporting URL of a ethstats service (nodename:secret@host:port)

- ```gpo.blocks```: Number of recent blocks to check for gas prices (default: 20)
Expand Down
23 changes: 21 additions & 2 deletions internal/cli/bootnode.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import (
"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/internal/cli/flagset"
"github.com/ethereum/go-ethereum/internal/cli/server"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/p2p/discover"
"github.com/ethereum/go-ethereum/p2p/enode"
Expand All @@ -27,6 +28,7 @@ type BootnodeCommand struct {

listenAddr string
v5 bool
verbosity int
logLevel string
nat string
nodeKey string
Expand Down Expand Up @@ -64,10 +66,16 @@ func (b *BootnodeCommand) Flags() *flagset.Flagset {
Usage: "Enable UDP v5",
Value: &b.v5,
})
flags.IntFlag(&flagset.IntFlag{
Name: "verbosity",
Default: 3,
Usage: "Logging verbosity (5=trace|4=debug|3=info|2=warn|1=error|0=crit)",
Value: &b.verbosity,
})
flags.StringFlag(&flagset.StringFlag{
Name: "log-level",
Default: "info",
Usage: "Log level (trace|debug|info|warn|error|crit)",
Usage: "log level (trace|debug|info|warn|error|crit), will be deprecated soon. Use verbosity instead",
Value: &b.logLevel,
})
flags.StringFlag(&flagset.StringFlag{
Expand Down Expand Up @@ -114,7 +122,18 @@ func (b *BootnodeCommand) Run(args []string) int {

glogger := log.NewGlogHandler(log.StreamHandler(os.Stderr, log.TerminalFormat(false)))

lvl, err := log.LvlFromString(strings.ToLower(b.logLevel))
var logInfo string

if b.verbosity != 0 && b.logLevel != "" {
b.UI.Warn(fmt.Sprintf("Both verbosity and log-level provided, using verbosity: %v", b.verbosity))
logInfo = server.VerbosityIntToString(b.verbosity)
} else if b.verbosity != 0 {
logInfo = server.VerbosityIntToString(b.verbosity)
} else {
logInfo = b.logLevel
}

lvl, err := log.LvlFromString(strings.ToLower(logInfo))
if err == nil {
glogger.Verbosity(lvl)
} else {
Expand Down
27 changes: 27 additions & 0 deletions internal/cli/server/command.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (

"github.com/maticnetwork/heimdall/cmd/heimdalld/service"
"github.com/mitchellh/cli"
"github.com/pelletier/go-toml"

"github.com/ethereum/go-ethereum/log"
)
Expand Down Expand Up @@ -90,6 +91,32 @@ func (c *Command) extractFlags(args []string) error {
}
}

// nolint: nestif
// check for log-level and verbosity here
if c.configFile != "" {
data, _ := toml.LoadFile(c.configFile)
if data.Has("verbosity") && data.Has("log-level") {
log.Warn("Config contains both, verbosity and log-level, log-level will be deprecated soon. Use verbosity only.", "using", data.Get("verbosity"))
} else if !data.Has("verbosity") && data.Has("log-level") {
log.Warn("Config contains log-level only, note that log-level will be deprecated soon. Use verbosity instead.", "using", data.Get("log-level"))
config.Verbosity = VerbosityStringToInt(strings.ToLower(data.Get("log-level").(string)))
}
} else {
tempFlag := 0
for _, val := range args {
if (strings.HasPrefix(val, "-verbosity") || strings.HasPrefix(val, "--verbosity")) && config.LogLevel != "" {
tempFlag = 1
break
}
}
if tempFlag == 1 {
log.Warn("Both, verbosity and log-level flags are provided, log-level will be deprecated soon. Use verbosity only.", "using", config.Verbosity)
} else if tempFlag == 0 && config.LogLevel != "" {
log.Warn("Only log-level flag is provided, note that log-level will be deprecated soon. Use verbosity instead.", "using", config.LogLevel)
config.Verbosity = VerbosityStringToInt(strings.ToLower(config.LogLevel))
}
}

c.config = &config

return nil
Expand Down
6 changes: 5 additions & 1 deletion internal/cli/server/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,9 @@ type Config struct {
// RequiredBlocks is a list of required (block number, hash) pairs to accept
RequiredBlocks map[string]string `hcl:"eth.requiredblocks,optional" toml:"eth.requiredblocks,optional"`

// Verbosity is the level of the logs to put out
Verbosity int `hcl:"verbosity,optional" toml:"verbosity,optional"`

// LogLevel is the level of the logs to put out
LogLevel string `hcl:"log-level,optional" toml:"log-level,optional"`

Expand Down Expand Up @@ -445,7 +448,8 @@ func DefaultConfig() *Config {
Chain: "mainnet",
Identity: Hostname(),
RequiredBlocks: map[string]string{},
LogLevel: "INFO",
Verbosity: 3,
LogLevel: "",
DataDir: DefaultDataDir(),
Ancient: "",
P2P: &P2PConfig{
Expand Down
8 changes: 7 additions & 1 deletion internal/cli/server/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,15 @@ func (c *Command) Flags() *flagset.Flagset {
Default: c.cliConfig.Identity,
HideDefaultFromDoc: true,
})
f.IntFlag(&flagset.IntFlag{
Name: "verbosity",
Usage: "Logging verbosity for the server (5=trace|4=debug|3=info|2=warn|1=error|0=crit), default = 3",
Value: &c.cliConfig.Verbosity,
Default: c.cliConfig.Verbosity,
})
f.StringFlag(&flagset.StringFlag{
Name: "log-level",
Usage: "Set log level for the server",
Usage: "Log level for the server (trace|debug|info|warn|error|crit), will be deprecated soon. Use verbosity instead",
Value: &c.cliConfig.LogLevel,
Default: c.cliConfig.LogLevel,
})
Expand Down
28 changes: 27 additions & 1 deletion internal/cli/server/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,14 +68,40 @@ func WithGRPCListener(lis net.Listener) serverOption {
}
}

func VerbosityIntToString(verbosity int) string {
mapIntToString := map[int]string{
5: "trace",
4: "debug",
3: "info",
2: "warn",
1: "error",
0: "crit",
}

return mapIntToString[verbosity]
}

func VerbosityStringToInt(loglevel string) int {
mapStringToInt := map[string]int{
"trace": 5,
"debug": 4,
"info": 3,
"warn": 2,
"error": 1,
"crit": 0,
}

return mapStringToInt[loglevel]
}

//nolint:gocognit
func NewServer(config *Config, opts ...serverOption) (*Server, error) {
srv := &Server{
config: config,
}

// start the logger
setupLogger(config.LogLevel)
setupLogger(VerbosityIntToString(config.Verbosity))

var err error

Expand Down
2 changes: 1 addition & 1 deletion packaging/templates/mainnet-v1/archive/config.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
chain = "mainnet"
# identity = "node_name"
# log-level = "INFO"
# verbosity = 3
datadir = "/var/lib/bor/data"
# ancient = ""
# keystore = ""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
chain = "mainnet"
# identity = "node_name"
# log-level = "INFO"
# verbosity = 3
datadir = "/var/lib/bor/data"
# ancient = ""
# keystore = ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

chain = "mainnet"
# identity = "node_name"
# log-level = "INFO"
# verbosity = 3
datadir = "/var/lib/bor/data"
# ancient = ""
# keystore = "$BOR_DIR/keystore"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

chain = "mainnet"
# identity = "node_name"
# log-level = "INFO"
# verbosity = 3
datadir = "/var/lib/bor/data"
# ancient = ""
# keystore = "$BOR_DIR/keystore"
Expand Down
2 changes: 1 addition & 1 deletion packaging/templates/testnet-v4/archive/config.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
chain = "mumbai"
# identity = "node_name"
# log-level = "INFO"
# verbosity = 3
datadir = "/var/lib/bor/data"
# ancient = ""
# keystore = ""
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
chain = "mumbai"
# identity = "node_name"
# log-level = "INFO"
# verbosity = 3
datadir = "/var/lib/bor/data"
# ancient = ""
# keystore = ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

chain = "mumbai"
# identity = "node_name"
# log-level = "INFO"
# verbosity = 3
datadir = "/var/lib/bor/data"
# ancient = ""
# keystore = "$BOR_DIR/keystore"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

chain = "mumbai"
# identity = "node_name"
# log-level = "INFO"
# verbosity = 3
datadir = "/var/lib/bor/data"
# ancient = ""
# keystore = "$BOR_DIR/keystore"
Expand Down
8 changes: 4 additions & 4 deletions scripts/getconfig.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ var flagMap = map[string][]string{
var nameTagMap = map[string]string{
"chain": "chain",
"identity": "identity",
"log-level": "log-level",
"verbosity": "verbosity",
"datadir": "datadir",
"keystore": "keystore",
"syncmode": "syncmode",
Expand Down Expand Up @@ -215,15 +215,15 @@ var replacedFlagsMapFlagAndValue = map[string]map[string]map[string]string{
},
"verbosity": {
"flag": {
"verbosity": "log-level",
"verbosity": "verbosity",
},
"value": {
"0": "SILENT",
"0": "CRIT",
"1": "ERROR",
"2": "WARN",
"3": "INFO",
"4": "DEBUG",
"5": "DETAIL",
"5": "TRACE",
},
},
}
Expand Down