Skip to content

Commit

Permalink
Refactor, standardize log.Crit() to be log.Fatal()
Browse files Browse the repository at this point in the history
  • Loading branch information
Djadih committed May 16, 2023
1 parent cad28c2 commit 749785f
Show file tree
Hide file tree
Showing 42 changed files with 193 additions and 253 deletions.
9 changes: 7 additions & 2 deletions cmd/go-quai/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,10 +31,11 @@ import (
"github.com/dominant-strategies/go-quai/internal/debug"
"github.com/dominant-strategies/go-quai/internal/flags"
"github.com/dominant-strategies/go-quai/internal/quaiapi"
"github.com/dominant-strategies/go-quai/log"
"github.com/dominant-strategies/go-quai/metrics"
"github.com/dominant-strategies/go-quai/node"
"github.com/dominant-strategies/go-quai/params"
"github.com/dominant-strategies/go-quai/log"

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

Expand All @@ -47,7 +48,7 @@ var (
gitCommit = ""
gitDate = ""
// The app that holds all commands and flags.
app = flags.NewApp(gitCommit, gitDate, "the go-ethereum command line interface")
app = flags.NewApp(gitCommit, gitDate, "the go-quai command line interface")
// flags that configure the node
nodeFlags = []cli.Flag{
utils.IdentityFlag,
Expand Down Expand Up @@ -229,6 +230,7 @@ func prepare(ctx *cli.Context) {
case !ctx.GlobalIsSet(utils.NetworkIdFlag.Name):
netname = "Colosseum testnet"
}

welcome := fmt.Sprintf("Starting Quai %s on %s", params.Version.Full(), netname)
log.Info(welcome)
// If we're a full node on colosseum without --cache specified, bump default cache allowance
Expand Down Expand Up @@ -261,6 +263,9 @@ func quai(ctx *cli.Context) error {
return fmt.Errorf("invalid command: %q", args[0])
}

// Setup logger.
log.ConfigureLogger(ctx)

prepare(ctx)
stack, backend := makeFullNode(ctx)
defer stack.Close()
Expand Down
4 changes: 2 additions & 2 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -719,7 +719,7 @@ func setBootstrapNodes(ctx *cli.Context, cfg *p2p.Config) {
if url != "" {
node, err := enode.Parse(enode.ValidSchemes, url+cfg.ListenAddr)
if err != nil {
log.Crit("Bootstrap URL invalid", "enode", url, "err", err)
log.Fatal("Bootstrap URL invalid", "enode", url, "err", err)
continue
}
cfg.BootstrapNodes = append(cfg.BootstrapNodes, node)
Expand Down Expand Up @@ -1232,7 +1232,7 @@ func CheckExclusive(ctx *cli.Context, args ...interface{}) {
func SetGlobalVars(ctx *cli.Context) {
// Configure global NodeLocation
if !ctx.GlobalIsSet(RegionFlag.Name) && ctx.GlobalIsSet(ZoneFlag.Name) {
log.Crit("zone idx given, but missing region idx!")
log.Fatal("zone idx given, but missing region idx!")
}
if ctx.GlobalIsSet(RegionFlag.Name) {
region := ctx.GlobalInt(RegionFlag.Name)
Expand Down
10 changes: 5 additions & 5 deletions consensus/blake3pow/blake3pow.go
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ type Blake3pow struct {
// packages.
func New(config Config, notify []string, noverify bool) *Blake3pow {
if config.Log == nil {
config.Log = log.Root()
config.Log = log.Log
}
blake3pow := &Blake3pow{
config: config,
Expand All @@ -102,7 +102,7 @@ func NewFaker() *Blake3pow {
return &Blake3pow{
config: Config{
PowMode: ModeFake,
Log: log.Root(),
Log: log.Log,
},
}
}
Expand All @@ -114,7 +114,7 @@ func NewFakeFailer(fail uint64) *Blake3pow {
return &Blake3pow{
config: Config{
PowMode: ModeFake,
Log: log.Root(),
Log: log.Log,
},
fakeFail: fail,
}
Expand All @@ -127,7 +127,7 @@ func NewFakeDelayer(delay time.Duration) *Blake3pow {
return &Blake3pow{
config: Config{
PowMode: ModeFake,
Log: log.Root(),
Log: log.Log,
},
fakeDelay: delay,
}
Expand All @@ -139,7 +139,7 @@ func NewFullFaker() *Blake3pow {
return &Blake3pow{
config: Config{
PowMode: ModeFullFake,
Log: log.Root(),
Log: log.Log,
},
}
}
Expand Down
3 changes: 2 additions & 1 deletion consensus/blake3pow/sealer.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/dominant-strategies/go-quai/common"
"github.com/dominant-strategies/go-quai/common/hexutil"
"github.com/dominant-strategies/go-quai/core/types"
"github.com/dominant-strategies/go-quai/log"
)

const (
Expand Down Expand Up @@ -122,7 +123,7 @@ func (blake3pow *Blake3pow) mine(header *types.Header, id int, seed uint64, abor
nonce = seed
powBuffer = new(big.Int)
)
logger := blake3pow.config.Log.New("miner", id)
logger := log.Log
logger.Trace("Started blake3pow search for new nonces", "seed", seed)
search:
for {
Expand Down
2 changes: 1 addition & 1 deletion core/chain_indexer.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ func NewChainIndexer(chainDb ethdb.Database, indexDb ethdb.Database, backend Cha
sectionSize: section,
confirmsReq: confirm,
throttling: throttling,
log: log.New("type", kind),
log: log.Log,
}
// Initialize database dependent fields and start the updater
c.loadValidSections()
Expand Down
Loading

0 comments on commit 749785f

Please sign in to comment.