aboutsummaryrefslogtreecommitdiffstats
path: root/cmd/geth
diff options
context:
space:
mode:
authorPéter Szilágyi <peterke@gmail.com>2017-02-22 20:10:07 +0800
committerPéter Szilágyi <peterke@gmail.com>2017-02-23 18:16:44 +0800
commitd4fd06c3dc6cd6d2dbd2bfebfee5bcb46a504851 (patch)
tree17c93170551d3eeabe2935de1765f157007f0dc2 /cmd/geth
parent47af53f9aaf9aa7b12cd976eb150ccf3d64da6fd (diff)
downloaddexon-d4fd06c3dc6cd6d2dbd2bfebfee5bcb46a504851.tar
dexon-d4fd06c3dc6cd6d2dbd2bfebfee5bcb46a504851.tar.gz
dexon-d4fd06c3dc6cd6d2dbd2bfebfee5bcb46a504851.tar.bz2
dexon-d4fd06c3dc6cd6d2dbd2bfebfee5bcb46a504851.tar.lz
dexon-d4fd06c3dc6cd6d2dbd2bfebfee5bcb46a504851.tar.xz
dexon-d4fd06c3dc6cd6d2dbd2bfebfee5bcb46a504851.tar.zst
dexon-d4fd06c3dc6cd6d2dbd2bfebfee5bcb46a504851.zip
all: blidly swap out glog to our log15, logs need rework
Diffstat (limited to 'cmd/geth')
-rw-r--r--cmd/geth/accountcmd.go54
-rw-r--r--cmd/geth/chaincmd.go43
-rw-r--r--cmd/geth/consolecmd.go16
-rw-r--r--cmd/geth/main.go25
-rw-r--r--cmd/geth/misccmd.go5
-rw-r--r--cmd/geth/monitorcmd.go19
6 files changed, 90 insertions, 72 deletions
diff --git a/cmd/geth/accountcmd.go b/cmd/geth/accountcmd.go
index cd398eadb..b7c411e82 100644
--- a/cmd/geth/accountcmd.go
+++ b/cmd/geth/accountcmd.go
@@ -19,14 +19,14 @@ package main
import (
"fmt"
"io/ioutil"
+ "os"
"github.com/ethereum/go-ethereum/accounts"
"github.com/ethereum/go-ethereum/accounts/keystore"
"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/console"
"github.com/ethereum/go-ethereum/crypto"
- "github.com/ethereum/go-ethereum/logger"
- "github.com/ethereum/go-ethereum/logger/glog"
+ "github.com/ethereum/go-ethereum/log"
"gopkg.in/urfave/cli.v1"
)
@@ -196,18 +196,19 @@ func accountList(ctx *cli.Context) error {
func unlockAccount(ctx *cli.Context, ks *keystore.KeyStore, address string, i int, passwords []string) (accounts.Account, string) {
account, err := utils.MakeAddress(ks, address)
if err != nil {
- utils.Fatalf("Could not list accounts: %v", err)
+ fmt.Printf("Fatal: Could not list accounts: %v\n", err)
+ os.Exit(1)
}
for trials := 0; trials < 3; trials++ {
prompt := fmt.Sprintf("Unlocking account %s | Attempt %d/%d", address, trials+1, 3)
password := getPassPhrase(prompt, false, i, passwords)
err = ks.Unlock(account, password)
if err == nil {
- glog.V(logger.Info).Infof("Unlocked account %x", account.Address)
+ log.Info(fmt.Sprintf("Unlocked account %x", account.Address))
return account, password
}
if err, ok := err.(*keystore.AmbiguousAddrError); ok {
- glog.V(logger.Info).Infof("Unlocked account %x", account.Address)
+ log.Info(fmt.Sprintf("Unlocked account %x", account.Address))
return ambiguousAddrRecovery(ks, err, password), password
}
if err != keystore.ErrDecrypt {
@@ -216,7 +217,9 @@ func unlockAccount(ctx *cli.Context, ks *keystore.KeyStore, address string, i in
}
}
// All trials expended to unlock account, bail out
- utils.Fatalf("Failed to unlock account %s (%v)", address, err)
+ fmt.Printf("Fatal: Failed to unlock account %s (%v)\n", address, err)
+ os.Exit(1)
+
return accounts.Account{}, ""
}
@@ -236,15 +239,18 @@ func getPassPhrase(prompt string, confirmation bool, i int, passwords []string)
}
password, err := console.Stdin.PromptPassword("Passphrase: ")
if err != nil {
- utils.Fatalf("Failed to read passphrase: %v", err)
+ fmt.Printf("Fatal: Failed to read passphrase: %v\n", err)
+ os.Exit(1)
}
if confirmation {
confirm, err := console.Stdin.PromptPassword("Repeat passphrase: ")
if err != nil {
- utils.Fatalf("Failed to read passphrase confirmation: %v", err)
+ fmt.Printf("Fatal: Failed to read passphrase confirmation: %v\n", err)
+ os.Exit(1)
}
if password != confirm {
- utils.Fatalf("Passphrases do not match")
+ fmt.Printf("Fatal: Passphrases do not match\n")
+ os.Exit(1)
}
}
return password
@@ -264,7 +270,8 @@ func ambiguousAddrRecovery(ks *keystore.KeyStore, err *keystore.AmbiguousAddrErr
}
}
if match == nil {
- utils.Fatalf("None of the listed files could be unlocked.")
+ fmt.Printf("Fatal: None of the listed files could be unlocked.\n")
+ os.Exit(1)
}
fmt.Printf("Your passphrase unlocked %s\n", match.URL)
fmt.Println("In order to avoid this warning, you need to remove the following duplicate key files:")
@@ -284,7 +291,8 @@ func accountCreate(ctx *cli.Context) error {
ks := stack.AccountManager().Backends(keystore.KeyStoreType)[0].(*keystore.KeyStore)
account, err := ks.NewAccount(password)
if err != nil {
- utils.Fatalf("Failed to create account: %v", err)
+ fmt.Printf("Fatal: Failed to create account: %v\n", err)
+ os.Exit(1)
}
fmt.Printf("Address: {%x}\n", account.Address)
return nil
@@ -294,7 +302,8 @@ func accountCreate(ctx *cli.Context) error {
// one, also providing the possibility to change the pass-phrase.
func accountUpdate(ctx *cli.Context) error {
if len(ctx.Args()) == 0 {
- utils.Fatalf("No accounts specified to update")
+ fmt.Printf("Fatal: No accounts specified to update\n")
+ os.Exit(1)
}
stack := utils.MakeNode(ctx, clientIdentifier, gitCommit)
ks := stack.AccountManager().Backends(keystore.KeyStoreType)[0].(*keystore.KeyStore)
@@ -302,7 +311,8 @@ func accountUpdate(ctx *cli.Context) error {
account, oldPassword := unlockAccount(ctx, ks, ctx.Args().First(), 0, nil)
newPassword := getPassPhrase("Please give a new password. Do not forget this password.", true, 0, nil)
if err := ks.Update(account, oldPassword, newPassword); err != nil {
- utils.Fatalf("Could not update the account: %v", err)
+ fmt.Printf("Fatal: Could not update the account: %v\n", err)
+ os.Exit(1)
}
return nil
}
@@ -310,11 +320,13 @@ func accountUpdate(ctx *cli.Context) error {
func importWallet(ctx *cli.Context) error {
keyfile := ctx.Args().First()
if len(keyfile) == 0 {
- utils.Fatalf("keyfile must be given as argument")
+ fmt.Printf("Fatal: keyfile must be given as argument\n")
+ os.Exit(1)
}
keyJson, err := ioutil.ReadFile(keyfile)
if err != nil {
- utils.Fatalf("Could not read wallet file: %v", err)
+ fmt.Printf("Fatal: Could not read wallet file: %v\n", err)
+ os.Exit(1)
}
stack := utils.MakeNode(ctx, clientIdentifier, gitCommit)
@@ -323,7 +335,8 @@ func importWallet(ctx *cli.Context) error {
ks := stack.AccountManager().Backends(keystore.KeyStoreType)[0].(*keystore.KeyStore)
acct, err := ks.ImportPreSaleKey(keyJson, passphrase)
if err != nil {
- utils.Fatalf("%v", err)
+ fmt.Printf("Fatal: %v\n", err)
+ os.Exit(1)
}
fmt.Printf("Address: {%x}\n", acct.Address)
return nil
@@ -332,11 +345,13 @@ func importWallet(ctx *cli.Context) error {
func accountImport(ctx *cli.Context) error {
keyfile := ctx.Args().First()
if len(keyfile) == 0 {
- utils.Fatalf("keyfile must be given as argument")
+ fmt.Printf("Fatal: keyfile must be given as argument\n")
+ os.Exit(1)
}
key, err := crypto.LoadECDSA(keyfile)
if err != nil {
- utils.Fatalf("Failed to load the private key: %v", err)
+ fmt.Printf("Fatal: Failed to load the private key: %v\n", err)
+ os.Exit(1)
}
stack := utils.MakeNode(ctx, clientIdentifier, gitCommit)
passphrase := getPassPhrase("Your new account is locked with a password. Please give a password. Do not forget this password.", true, 0, utils.MakePasswordList(ctx))
@@ -344,7 +359,8 @@ func accountImport(ctx *cli.Context) error {
ks := stack.AccountManager().Backends(keystore.KeyStoreType)[0].(*keystore.KeyStore)
acct, err := ks.ImportECDSA(key, passphrase)
if err != nil {
- utils.Fatalf("Could not create the account: %v", err)
+ fmt.Printf("Fatal: Could not create the account: %v\n", err)
+ os.Exit(1)
}
fmt.Printf("Address: {%x}\n", acct.Address)
return nil
diff --git a/cmd/geth/chaincmd.go b/cmd/geth/chaincmd.go
index f38ee046f..1127a1090 100644
--- a/cmd/geth/chaincmd.go
+++ b/cmd/geth/chaincmd.go
@@ -32,8 +32,7 @@ import (
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/ethdb"
- "github.com/ethereum/go-ethereum/logger"
- "github.com/ethereum/go-ethereum/logger/glog"
+ "github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/trie"
"github.com/syndtr/goleveldb/leveldb/util"
"gopkg.in/urfave/cli.v1"
@@ -113,7 +112,7 @@ Use "ethereum dump 0" to dump the genesis block.
func initGenesis(ctx *cli.Context) error {
genesisPath := ctx.Args().First()
if len(genesisPath) == 0 {
- utils.Fatalf("must supply path to genesis JSON file")
+ log.Crit(fmt.Sprintf("must supply path to genesis JSON file"))
}
stack := makeFullNode(ctx)
@@ -121,21 +120,21 @@ func initGenesis(ctx *cli.Context) error {
genesisFile, err := os.Open(genesisPath)
if err != nil {
- utils.Fatalf("failed to read genesis file: %v", err)
+ log.Crit(fmt.Sprintf("failed to read genesis file: %v", err))
}
defer genesisFile.Close()
block, err := core.WriteGenesisBlock(chaindb, genesisFile)
if err != nil {
- utils.Fatalf("failed to write genesis block: %v", err)
+ log.Crit(fmt.Sprintf("failed to write genesis block: %v", err))
}
- glog.V(logger.Info).Infof("successfully wrote genesis block and/or chain rule set: %x", block.Hash())
+ log.Info(fmt.Sprintf("successfully wrote genesis block and/or chain rule set: %x", block.Hash()))
return nil
}
func importChain(ctx *cli.Context) error {
if len(ctx.Args()) != 1 {
- utils.Fatalf("This command requires an argument.")
+ log.Crit(fmt.Sprintf("This command requires an argument."))
}
stack := makeFullNode(ctx)
chain, chainDb := utils.MakeChain(ctx, stack)
@@ -159,7 +158,7 @@ func importChain(ctx *cli.Context) error {
// Import the chain
start := time.Now()
if err := utils.ImportChain(chain, ctx.Args().First()); err != nil {
- utils.Fatalf("Import error: %v", err)
+ log.Crit(fmt.Sprintf("Import error: %v", err))
}
fmt.Printf("Import done in %v.\n\n", time.Since(start))
@@ -168,7 +167,7 @@ func importChain(ctx *cli.Context) error {
stats, err := db.LDB().GetProperty("leveldb.stats")
if err != nil {
- utils.Fatalf("Failed to read database stats: %v", err)
+ log.Crit(fmt.Sprintf("Failed to read database stats: %v", err))
}
fmt.Println(stats)
fmt.Printf("Trie cache misses: %d\n", trie.CacheMisses())
@@ -187,13 +186,13 @@ func importChain(ctx *cli.Context) error {
start = time.Now()
fmt.Println("Compacting entire database...")
if err = db.LDB().CompactRange(util.Range{}); err != nil {
- utils.Fatalf("Compaction failed: %v", err)
+ log.Crit(fmt.Sprintf("Compaction failed: %v", err))
}
fmt.Printf("Compaction done in %v.\n\n", time.Since(start))
stats, err = db.LDB().GetProperty("leveldb.stats")
if err != nil {
- utils.Fatalf("Failed to read database stats: %v", err)
+ log.Crit(fmt.Sprintf("Failed to read database stats: %v", err))
}
fmt.Println(stats)
@@ -202,7 +201,7 @@ func importChain(ctx *cli.Context) error {
func exportChain(ctx *cli.Context) error {
if len(ctx.Args()) < 1 {
- utils.Fatalf("This command requires an argument.")
+ log.Crit(fmt.Sprintf("This command requires an argument."))
}
stack := makeFullNode(ctx)
chain, _ := utils.MakeChain(ctx, stack)
@@ -217,16 +216,16 @@ func exportChain(ctx *cli.Context) error {
first, ferr := strconv.ParseInt(ctx.Args().Get(1), 10, 64)
last, lerr := strconv.ParseInt(ctx.Args().Get(2), 10, 64)
if ferr != nil || lerr != nil {
- utils.Fatalf("Export error in parsing parameters: block number not an integer\n")
+ log.Crit(fmt.Sprintf("Export error in parsing parameters: block number not an integer\n"))
}
if first < 0 || last < 0 {
- utils.Fatalf("Export error: block number must be greater than 0\n")
+ log.Crit(fmt.Sprintf("Export error: block number must be greater than 0\n"))
}
err = utils.ExportAppendChain(chain, fp, uint64(first), uint64(last))
}
if err != nil {
- utils.Fatalf("Export error: %v\n", err)
+ log.Crit(fmt.Sprintf("Export error: %v\n", err))
}
fmt.Printf("Export done in %v", time.Since(start))
return nil
@@ -244,7 +243,7 @@ func removeDB(ctx *cli.Context) error {
confirm, err := console.Stdin.PromptConfirm("Remove this database?")
switch {
case err != nil:
- utils.Fatalf("%v", err)
+ log.Crit(fmt.Sprintf("%v", err))
case !confirm:
fmt.Println("Operation aborted")
default:
@@ -257,7 +256,7 @@ func removeDB(ctx *cli.Context) error {
}
func upgradeDB(ctx *cli.Context) error {
- glog.Infoln("Upgrading blockchain database")
+ log.Info(fmt.Sprint("Upgrading blockchain database"))
stack := utils.MakeNode(ctx, clientIdentifier, gitCommit)
chain, chainDb := utils.MakeChain(ctx, stack)
@@ -270,7 +269,7 @@ func upgradeDB(ctx *cli.Context) error {
filename := fmt.Sprintf("blockchain_%d_%s.chain", bcVersion, time.Now().Format("20060102_150405"))
exportFile := filepath.Join(ctx.GlobalString(utils.DataDirFlag.Name), filename)
if err := utils.ExportChain(chain, exportFile); err != nil {
- utils.Fatalf("Unable to export chain for reimport %s", err)
+ log.Crit(fmt.Sprintf("Unable to export chain for reimport %s", err))
}
chainDb.Close()
if dir := dbDirectory(chainDb); dir != "" {
@@ -283,10 +282,10 @@ func upgradeDB(ctx *cli.Context) error {
err := utils.ImportChain(chain, exportFile)
chainDb.Close()
if err != nil {
- utils.Fatalf("Import error %v (a backup is made in %s, use the import command to import it)", err, exportFile)
+ log.Crit(fmt.Sprintf("Import error %v (a backup is made in %s, use the import command to import it)", err, exportFile))
} else {
os.Remove(exportFile)
- glog.Infoln("Import finished")
+ log.Info(fmt.Sprint("Import finished"))
}
return nil
}
@@ -312,11 +311,11 @@ func dump(ctx *cli.Context) error {
}
if block == nil {
fmt.Println("{}")
- utils.Fatalf("block not found")
+ log.Crit(fmt.Sprintf("block not found"))
} else {
state, err := state.New(block.Root(), chainDb)
if err != nil {
- utils.Fatalf("could not create new state: %v", err)
+ log.Crit(fmt.Sprintf("could not create new state: %v", err))
}
fmt.Printf("%s\n", state.Dump())
}
diff --git a/cmd/geth/consolecmd.go b/cmd/geth/consolecmd.go
index b1c435e00..4009e3e33 100644
--- a/cmd/geth/consolecmd.go
+++ b/cmd/geth/consolecmd.go
@@ -17,12 +17,14 @@
package main
import (
+ "fmt"
"os"
"os/signal"
"strings"
"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/console"
+ "github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/node"
"github.com/ethereum/go-ethereum/rpc"
"gopkg.in/urfave/cli.v1"
@@ -78,7 +80,7 @@ func localConsole(ctx *cli.Context) error {
// Attach to the newly started node and start the JavaScript console
client, err := node.Attach()
if err != nil {
- utils.Fatalf("Failed to attach to the inproc geth: %v", err)
+ log.Crit(fmt.Sprintf("Failed to attach to the inproc geth: %v", err))
}
config := console.Config{
DataDir: node.DataDir(),
@@ -88,7 +90,7 @@ func localConsole(ctx *cli.Context) error {
}
console, err := console.New(config)
if err != nil {
- utils.Fatalf("Failed to start the JavaScript console: %v", err)
+ log.Crit(fmt.Sprintf("Failed to start the JavaScript console: %v", err))
}
defer console.Stop(false)
@@ -110,7 +112,7 @@ func remoteConsole(ctx *cli.Context) error {
// Attach to a remotely running geth instance and start the JavaScript console
client, err := dialRPC(ctx.Args().First())
if err != nil {
- utils.Fatalf("Unable to attach to remote geth: %v", err)
+ log.Crit(fmt.Sprintf("Unable to attach to remote geth: %v", err))
}
config := console.Config{
DataDir: utils.MakeDataDir(ctx),
@@ -120,7 +122,7 @@ func remoteConsole(ctx *cli.Context) error {
}
console, err := console.New(config)
if err != nil {
- utils.Fatalf("Failed to start the JavaScript console: %v", err)
+ log.Crit(fmt.Sprintf("Failed to start the JavaScript console: %v", err))
}
defer console.Stop(false)
@@ -162,7 +164,7 @@ func ephemeralConsole(ctx *cli.Context) error {
// Attach to the newly started node and start the JavaScript console
client, err := node.Attach()
if err != nil {
- utils.Fatalf("Failed to attach to the inproc geth: %v", err)
+ log.Crit(fmt.Sprintf("Failed to attach to the inproc geth: %v", err))
}
config := console.Config{
DataDir: node.DataDir(),
@@ -172,14 +174,14 @@ func ephemeralConsole(ctx *cli.Context) error {
}
console, err := console.New(config)
if err != nil {
- utils.Fatalf("Failed to start the JavaScript console: %v", err)
+ log.Crit(fmt.Sprintf("Failed to start the JavaScript console: %v", err))
}
defer console.Stop(false)
// Evaluate each of the specified JavaScript files
for _, file := range ctx.Args() {
if err = console.Execute(file); err != nil {
- utils.Fatalf("Failed to execute %s: %v", file, err)
+ log.Crit(fmt.Sprintf("Failed to execute %s: %v", file, err))
}
}
// Wait for pending callbacks, but stop for Ctrl-C.
diff --git a/cmd/geth/main.go b/cmd/geth/main.go
index 7d98f6bb2..2bebccac7 100644
--- a/cmd/geth/main.go
+++ b/cmd/geth/main.go
@@ -34,8 +34,7 @@ import (
"github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/internal/debug"
- "github.com/ethereum/go-ethereum/logger"
- "github.com/ethereum/go-ethereum/logger/glog"
+ "github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/metrics"
"github.com/ethereum/go-ethereum/node"
"github.com/ethereum/go-ethereum/params"
@@ -204,11 +203,11 @@ func makeFullNode(ctx *cli.Context) *node.Node {
}{uint(params.VersionMajor<<16 | params.VersionMinor<<8 | params.VersionPatch), clientIdentifier, runtime.Version(), runtime.GOOS}
extra, err := rlp.EncodeToBytes(clientInfo)
if err != nil {
- glog.V(logger.Warn).Infoln("error setting canonical miner information:", err)
+ log.Warn(fmt.Sprint("error setting canonical miner information:", err))
}
if uint64(len(extra)) > params.MaximumExtraDataSize {
- glog.V(logger.Warn).Infoln("error setting canonical miner information: extra exceeds", params.MaximumExtraDataSize)
- glog.V(logger.Debug).Infof("extra: %x\n", extra)
+ log.Warn(fmt.Sprint("error setting canonical miner information: extra exceeds", params.MaximumExtraDataSize))
+ log.Debug(fmt.Sprintf("extra: %x\n", extra))
extra = nil
}
stack := utils.MakeNode(ctx, clientIdentifier, gitCommit)
@@ -236,7 +235,7 @@ func makeFullNode(ctx *cli.Context) *node.Node {
copy(config.Commit[:], commit)
return release.NewReleaseService(ctx, config)
}); err != nil {
- utils.Fatalf("Failed to register the Geth release oracle service: %v", err)
+ log.Crit(fmt.Sprintf("Failed to register the Geth release oracle service: %v", err))
}
return stack
}
@@ -266,14 +265,14 @@ func startNode(ctx *cli.Context, stack *node.Node) {
// Create an chain state reader for self-derivation
rpcClient, err := stack.Attach()
if err != nil {
- utils.Fatalf("Failed to attach to self: %v", err)
+ log.Crit(fmt.Sprintf("Failed to attach to self: %v", err))
}
stateReader := ethclient.NewClient(rpcClient)
// Open and self derive any wallets already attached
for _, wallet := range stack.AccountManager().Wallets() {
if err := wallet.Open(""); err != nil {
- glog.V(logger.Warn).Infof("Failed to open wallet %s: %v", wallet.URL(), err)
+ log.Warn(fmt.Sprintf("Failed to open wallet %s: %v", wallet.URL(), err))
} else {
wallet.SelfDerive(accounts.DefaultBaseDerivationPath, stateReader)
}
@@ -282,13 +281,13 @@ func startNode(ctx *cli.Context, stack *node.Node) {
for event := range events {
if event.Arrive {
if err := event.Wallet.Open(""); err != nil {
- glog.V(logger.Info).Infof("New wallet appeared: %s, failed to open: %s", event.Wallet.URL(), err)
+ log.Info(fmt.Sprintf("New wallet appeared: %s, failed to open: %s", event.Wallet.URL(), err))
} else {
- glog.V(logger.Info).Infof("New wallet appeared: %s, %s", event.Wallet.URL(), event.Wallet.Status())
+ log.Info(fmt.Sprintf("New wallet appeared: %s, %s", event.Wallet.URL(), event.Wallet.Status()))
event.Wallet.SelfDerive(accounts.DefaultBaseDerivationPath, stateReader)
}
} else {
- glog.V(logger.Info).Infof("Old wallet dropped: %s", event.Wallet.URL())
+ log.Info(fmt.Sprintf("Old wallet dropped: %s", event.Wallet.URL()))
event.Wallet.Close()
}
}
@@ -297,10 +296,10 @@ func startNode(ctx *cli.Context, stack *node.Node) {
if ctx.GlobalBool(utils.MiningEnabledFlag.Name) {
var ethereum *eth.Ethereum
if err := stack.Service(&ethereum); err != nil {
- utils.Fatalf("ethereum service not running: %v", err)
+ log.Crit(fmt.Sprintf("ethereum service not running: %v", err))
}
if err := ethereum.StartMining(ctx.GlobalInt(utils.MinerThreadsFlag.Name)); err != nil {
- utils.Fatalf("Failed to start mining: %v", err)
+ log.Crit(fmt.Sprintf("Failed to start mining: %v", err))
}
}
}
diff --git a/cmd/geth/misccmd.go b/cmd/geth/misccmd.go
index 077f1ad11..9cb161e1a 100644
--- a/cmd/geth/misccmd.go
+++ b/cmd/geth/misccmd.go
@@ -28,6 +28,7 @@ import (
"github.com/ethereum/ethash"
"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/eth"
+ "github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/params"
"gopkg.in/urfave/cli.v1"
)
@@ -68,7 +69,7 @@ The output of this command is supposed to be machine-readable.
func makedag(ctx *cli.Context) error {
args := ctx.Args()
wrongArgs := func() {
- utils.Fatalf(`Usage: geth makedag <block number> <outputdir>`)
+ log.Crit(fmt.Sprintf(`Usage: geth makedag <block number> <outputdir>`))
}
switch {
case len(args) == 2:
@@ -84,7 +85,7 @@ func makedag(ctx *cli.Context) error {
}
_, err = ioutil.ReadDir(dir)
if err != nil {
- utils.Fatalf("Can't find dir")
+ log.Crit(fmt.Sprintf("Can't find dir"))
}
fmt.Println("making DAG, this could take awhile...")
ethash.MakeDAG(blockNum, dir)
diff --git a/cmd/geth/monitorcmd.go b/cmd/geth/monitorcmd.go
index c63542f13..129a80181 100644
--- a/cmd/geth/monitorcmd.go
+++ b/cmd/geth/monitorcmd.go
@@ -26,6 +26,7 @@ import (
"time"
"github.com/ethereum/go-ethereum/cmd/utils"
+ "github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/node"
"github.com/ethereum/go-ethereum/rpc"
"github.com/gizak/termui"
@@ -76,14 +77,14 @@ func monitor(ctx *cli.Context) error {
// Attach to an Ethereum node over IPC or RPC
endpoint := ctx.String(monitorCommandAttachFlag.Name)
if client, err = dialRPC(endpoint); err != nil {
- utils.Fatalf("Unable to attach to geth node: %v", err)
+ log.Crit(fmt.Sprintf("Unable to attach to geth node: %v", err))
}
defer client.Close()
// Retrieve all the available metrics and resolve the user pattens
metrics, err := retrieveMetrics(client)
if err != nil {
- utils.Fatalf("Failed to retrieve system metrics: %v", err)
+ log.Crit(fmt.Sprintf("Failed to retrieve system metrics: %v", err))
}
monitored := resolveMetrics(metrics, ctx.Args())
if len(monitored) == 0 {
@@ -91,18 +92,18 @@ func monitor(ctx *cli.Context) error {
sort.Strings(list)
if len(list) > 0 {
- utils.Fatalf("No metrics specified.\n\nAvailable:\n - %s", strings.Join(list, "\n - "))
+ log.Crit(fmt.Sprintf("No metrics specified.\n\nAvailable:\n - %s", strings.Join(list, "\n - ")))
} else {
- utils.Fatalf("No metrics collected by geth (--%s).\n", utils.MetricsEnabledFlag.Name)
+ log.Crit(fmt.Sprintf("No metrics collected by geth (--%s).\n", utils.MetricsEnabledFlag.Name))
}
}
sort.Strings(monitored)
if cols := len(monitored) / ctx.Int(monitorCommandRowsFlag.Name); cols > 6 {
- utils.Fatalf("Requested metrics (%d) spans more that 6 columns:\n - %s", len(monitored), strings.Join(monitored, "\n - "))
+ log.Crit(fmt.Sprintf("Requested metrics (%d) spans more that 6 columns:\n - %s", len(monitored), strings.Join(monitored, "\n - ")))
}
// Create and configure the chart UI defaults
if err := termui.Init(); err != nil {
- utils.Fatalf("Unable to initialize terminal UI: %v", err)
+ log.Crit(fmt.Sprintf("Unable to initialize terminal UI: %v", err))
}
defer termui.Close()
@@ -186,7 +187,7 @@ func resolveMetric(metrics map[string]interface{}, pattern string, path string)
if len(parts) > 1 {
for _, variation := range strings.Split(parts[0], ",") {
if submetrics, ok := metrics[variation].(map[string]interface{}); !ok {
- utils.Fatalf("Failed to retrieve system metrics: %s", path+variation)
+ log.Crit(fmt.Sprintf("Failed to retrieve system metrics: %s", path+variation))
return nil
} else {
results = append(results, resolveMetric(submetrics, parts[1], path+variation+"/")...)
@@ -205,7 +206,7 @@ func resolveMetric(metrics map[string]interface{}, pattern string, path string)
results = append(results, expandMetrics(metric, path+variation+"/")...)
default:
- utils.Fatalf("Metric pattern resolved to unexpected type: %v", reflect.TypeOf(metric))
+ log.Crit(fmt.Sprintf("Metric pattern resolved to unexpected type: %v", reflect.TypeOf(metric)))
return nil
}
}
@@ -227,7 +228,7 @@ func expandMetrics(metrics map[string]interface{}, path string) []string {
list = append(list, expandMetrics(metric, path+name+"/")...)
default:
- utils.Fatalf("Metric pattern %s resolved to unexpected type: %v", path+name, reflect.TypeOf(metric))
+ log.Crit(fmt.Sprintf("Metric pattern %s resolved to unexpected type: %v", path+name, reflect.TypeOf(metric)))
return nil
}
}