aboutsummaryrefslogtreecommitdiffstats
path: root/cmd
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
parent47af53f9aaf9aa7b12cd976eb150ccf3d64da6fd (diff)
downloadgo-tangerine-d4fd06c3dc6cd6d2dbd2bfebfee5bcb46a504851.tar.gz
go-tangerine-d4fd06c3dc6cd6d2dbd2bfebfee5bcb46a504851.tar.zst
go-tangerine-d4fd06c3dc6cd6d2dbd2bfebfee5bcb46a504851.zip
all: blidly swap out glog to our log15, logs need rework
Diffstat (limited to 'cmd')
-rw-r--r--cmd/bootnode/main.go33
-rw-r--r--cmd/ethtest/main.go26
-rw-r--r--cmd/evm/main.go7
-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
-rw-r--r--cmd/gethrpctest/main.go21
-rw-r--r--cmd/swarm/main.go27
-rw-r--r--cmd/swarm/manifest.go91
-rw-r--r--cmd/swarm/upload.go4
-rw-r--r--cmd/utils/cmd.go25
-rw-r--r--cmd/utils/flags.go49
-rw-r--r--cmd/wnode/main.go44
16 files changed, 247 insertions, 242 deletions
diff --git a/cmd/bootnode/main.go b/cmd/bootnode/main.go
index 9b5ba1936..f8cc77f83 100644
--- a/cmd/bootnode/main.go
+++ b/cmd/bootnode/main.go
@@ -23,9 +23,8 @@ import (
"fmt"
"os"
- "github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/crypto"
- "github.com/ethereum/go-ethereum/logger/glog"
+ "github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/p2p/discover"
"github.com/ethereum/go-ethereum/p2p/discv5"
"github.com/ethereum/go-ethereum/p2p/nat"
@@ -42,39 +41,43 @@ func main() {
natdesc = flag.String("nat", "none", "port mapping mechanism (any|none|upnp|pmp|extip:<IP>)")
netrestrict = flag.String("netrestrict", "", "restrict network communication to the given IP networks (CIDR masks)")
runv5 = flag.Bool("v5", false, "run a v5 topic discovery bootnode")
+ verbosity = flag.Int("verbosity", int(log.LvlInfo), "log verbosity (0-9)")
+ vmodule = flag.String("vmodule", "", "log verbosity pattern")
nodeKey *ecdsa.PrivateKey
err error
)
- flag.Var(glog.GetVerbosity(), "verbosity", "log verbosity (0-9)")
- flag.Var(glog.GetVModule(), "vmodule", "log verbosity pattern")
- glog.SetToStderr(true)
flag.Parse()
+ glogger := log.NewGlogHandler(log.StreamHandler(os.Stderr, log.TerminalFormat()))
+ glogger.Verbosity(log.Lvl(*verbosity))
+ glogger.Vmodule(*vmodule)
+ log.Root().SetHandler(glogger)
+
natm, err := nat.Parse(*natdesc)
if err != nil {
- utils.Fatalf("-nat: %v", err)
+ log.Crit(fmt.Sprintf("-nat: %v", err))
}
switch {
case *genKey != "":
nodeKey, err = crypto.GenerateKey()
if err != nil {
- utils.Fatalf("could not generate key: %v", err)
+ log.Crit(fmt.Sprintf("could not generate key: %v", err))
}
if err = crypto.SaveECDSA(*genKey, nodeKey); err != nil {
- utils.Fatalf("%v", err)
+ log.Crit(fmt.Sprintf("%v", err))
}
case *nodeKeyFile == "" && *nodeKeyHex == "":
- utils.Fatalf("Use -nodekey or -nodekeyhex to specify a private key")
+ log.Crit(fmt.Sprintf("Use -nodekey or -nodekeyhex to specify a private key"))
case *nodeKeyFile != "" && *nodeKeyHex != "":
- utils.Fatalf("Options -nodekey and -nodekeyhex are mutually exclusive")
+ log.Crit(fmt.Sprintf("Options -nodekey and -nodekeyhex are mutually exclusive"))
case *nodeKeyFile != "":
if nodeKey, err = crypto.LoadECDSA(*nodeKeyFile); err != nil {
- utils.Fatalf("-nodekey: %v", err)
+ log.Crit(fmt.Sprintf("-nodekey: %v", err))
}
case *nodeKeyHex != "":
if nodeKey, err = crypto.HexToECDSA(*nodeKeyHex); err != nil {
- utils.Fatalf("-nodekeyhex: %v", err)
+ log.Crit(fmt.Sprintf("-nodekeyhex: %v", err))
}
}
@@ -87,17 +90,17 @@ func main() {
if *netrestrict != "" {
restrictList, err = netutil.ParseNetlist(*netrestrict)
if err != nil {
- utils.Fatalf("-netrestrict: %v", err)
+ log.Crit(fmt.Sprintf("-netrestrict: %v", err))
}
}
if *runv5 {
if _, err := discv5.ListenUDP(nodeKey, *listenAddr, natm, "", restrictList); err != nil {
- utils.Fatalf("%v", err)
+ log.Crit(fmt.Sprintf("%v", err))
}
} else {
if _, err := discover.ListenUDP(nodeKey, *listenAddr, natm, "", restrictList); err != nil {
- utils.Fatalf("%v", err)
+ log.Crit(fmt.Sprintf("%v", err))
}
}
diff --git a/cmd/ethtest/main.go b/cmd/ethtest/main.go
index 14b839579..a107c701f 100644
--- a/cmd/ethtest/main.go
+++ b/cmd/ethtest/main.go
@@ -25,7 +25,7 @@ import (
"path/filepath"
"strings"
- "github.com/ethereum/go-ethereum/logger/glog"
+ "github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/tests"
"gopkg.in/urfave/cli.v1"
@@ -70,7 +70,7 @@ var (
)
func runTestWithReader(test string, r io.Reader) error {
- glog.Infoln("runTest", test)
+ log.Info(fmt.Sprint("runTest", test))
var err error
switch strings.ToLower(test) {
case "bk", "block", "blocktest", "blockchaintest", "blocktests", "blockchaintests":
@@ -92,7 +92,7 @@ func runTestWithReader(test string, r io.Reader) error {
}
func getFiles(path string) ([]string, error) {
- glog.Infoln("getFiles", path)
+ log.Info(fmt.Sprint("getFiles", path))
var files []string
f, err := os.Open(path)
if err != nil {
@@ -113,7 +113,7 @@ func getFiles(path string) ([]string, error) {
// only go 1 depth and leave directory entires blank
if !v.IsDir() && v.Name()[len(v.Name())-len(testExtension):len(v.Name())] == testExtension {
files[i] = filepath.Join(path, v.Name())
- glog.Infoln("Found file", files[i])
+ log.Info(fmt.Sprint("Found file", files[i]))
}
}
case mode.IsRegular():
@@ -134,7 +134,7 @@ func runSuite(test, file string) {
}
for _, curTest := range tests {
- glog.Infoln("runSuite", curTest, file)
+ log.Info(fmt.Sprint("runSuite", curTest, file))
var err error
var files []string
if test == defaultTest {
@@ -149,11 +149,11 @@ func runSuite(test, file string) {
files, err = getFiles(file)
}
if err != nil {
- glog.Fatalln(err)
+ log.Crit(fmt.Sprint(err))
}
if len(files) == 0 {
- glog.Warningln("No files matched path")
+ log.Warn("No files matched path")
}
for _, curFile := range files {
// Skip blank entries
@@ -163,16 +163,16 @@ func runSuite(test, file string) {
r, err := os.Open(curFile)
if err != nil {
- glog.Fatalln(err)
+ log.Crit(fmt.Sprint(err))
}
defer r.Close()
err = runTestWithReader(curTest, r)
if err != nil {
if continueOnError {
- glog.Errorln(err)
+ log.Error(fmt.Sprint(err))
} else {
- glog.Fatalln(err)
+ log.Crit(fmt.Sprint(err))
}
}
}
@@ -190,14 +190,14 @@ func setupApp(c *cli.Context) error {
runSuite(flagTest, flagFile)
} else {
if err := runTestWithReader(flagTest, os.Stdin); err != nil {
- glog.Fatalln(err)
+ log.Crit(fmt.Sprint(err))
}
}
return nil
}
func main() {
- glog.SetToStderr(true)
+ log.Root().SetHandler(log.StreamHandler(os.Stderr, log.TerminalFormat()))
app := cli.NewApp()
app.Name = "ethtest"
@@ -216,7 +216,7 @@ func main() {
}
if err := app.Run(os.Args); err != nil {
- glog.Fatalln(err)
+ log.Crit(fmt.Sprint(err))
}
}
diff --git a/cmd/evm/main.go b/cmd/evm/main.go
index 0693d7cd3..86e2493ca 100644
--- a/cmd/evm/main.go
+++ b/cmd/evm/main.go
@@ -30,7 +30,7 @@ import (
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/core/vm/runtime"
"github.com/ethereum/go-ethereum/ethdb"
- "github.com/ethereum/go-ethereum/logger/glog"
+ "github.com/ethereum/go-ethereum/log"
"gopkg.in/urfave/cli.v1"
)
@@ -111,8 +111,9 @@ func init() {
}
func run(ctx *cli.Context) error {
- glog.SetToStderr(true)
- glog.SetV(ctx.GlobalInt(VerbosityFlag.Name))
+ glogger := log.NewGlogHandler(log.StreamHandler(os.Stderr, log.TerminalFormat()))
+ glogger.Verbosity(log.Lvl(ctx.GlobalInt(VerbosityFlag.Name)))
+ log.Root().SetHandler(glogger)
var (
db, _ = ethdb.NewMemDatabase()
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
}
}
diff --git a/cmd/gethrpctest/main.go b/cmd/gethrpctest/main.go
index 9e80ad05d..69a6074e7 100644
--- a/cmd/gethrpctest/main.go
+++ b/cmd/gethrpctest/main.go
@@ -19,7 +19,7 @@ package main
import (
"flag"
- "log"
+ "fmt"
"os"
"os/signal"
@@ -27,7 +27,7 @@ import (
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/eth"
"github.com/ethereum/go-ethereum/ethdb"
- "github.com/ethereum/go-ethereum/logger/glog"
+ "github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/node"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/tests"
@@ -46,35 +46,34 @@ func main() {
flag.Parse()
// Enable logging errors, we really do want to see those
- glog.SetV(2)
- glog.SetToStderr(true)
+ log.Root().SetHandler(log.LvlFilterHandler(log.LvlError, log.StreamHandler(os.Stderr, log.TerminalFormat())))
// Load the test suite to run the RPC against
tests, err := tests.LoadBlockTests(*testFile)
if err != nil {
- log.Fatalf("Failed to load test suite: %v", err)
+ log.Crit(fmt.Sprintf("Failed to load test suite: %v", err))
}
test, found := tests[*testName]
if !found {
- log.Fatalf("Requested test (%s) not found within suite", *testName)
+ log.Crit(fmt.Sprintf("Requested test (%s) not found within suite", *testName))
}
stack, err := MakeSystemNode(*testKey, test)
if err != nil {
- log.Fatalf("Failed to assemble test stack: %v", err)
+ log.Crit(fmt.Sprintf("Failed to assemble test stack: %v", err))
}
if err := stack.Start(); err != nil {
- log.Fatalf("Failed to start test node: %v", err)
+ log.Crit(fmt.Sprintf("Failed to start test node: %v", err))
}
defer stack.Stop()
- log.Println("Test node started...")
+ log.Info("Test node started...")
// Make sure the tests contained within the suite pass
if err := RunTest(stack, test); err != nil {
- log.Fatalf("Failed to run the pre-configured test: %v", err)
+ log.Crit(fmt.Sprintf("Failed to run the pre-configured test: %v", err))
}
- log.Println("Initial test suite passed...")
+ log.Info("Initial test suite passed...")
quit := make(chan os.Signal, 1)
signal.Notify(quit, os.Interrupt)
diff --git a/cmd/swarm/main.go b/cmd/swarm/main.go
index 5661b3f6e..84af69d7a 100644
--- a/cmd/swarm/main.go
+++ b/cmd/swarm/main.go
@@ -35,8 +35,7 @@ import (
"github.com/ethereum/go-ethereum/crypto"
"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/node"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/p2p/discover"
@@ -278,7 +277,7 @@ func bzzd(ctx *cli.Context) error {
signal.Notify(sigc, syscall.SIGTERM)
defer signal.Stop(sigc)
<-sigc
- glog.V(logger.Info).Infoln("Got sigterm, shutting down...")
+ log.Info(fmt.Sprint("Got sigterm, shutting down..."))
stack.Stop()
}()
networkId := ctx.GlobalUint64(SwarmNetworkIdFlag.Name)
@@ -308,7 +307,7 @@ func registerBzzService(ctx *cli.Context, stack *node.Node) {
bzzconfig, err := bzzapi.NewConfig(bzzdir, chbookaddr, prvkey, ctx.GlobalUint64(SwarmNetworkIdFlag.Name))
if err != nil {
- utils.Fatalf("unable to configure swarm: %v", err)
+ log.Crit(fmt.Sprintf("unable to configure swarm: %v", err))
}
bzzport := ctx.GlobalString(SwarmPortFlag.Name)
if len(bzzport) > 0 {
@@ -325,13 +324,13 @@ func registerBzzService(ctx *cli.Context, stack *node.Node) {
if len(ethapi) > 0 {
client, err = ethclient.Dial(ethapi)
if err != nil {
- utils.Fatalf("Can't connect: %v", err)
+ log.Crit(fmt.Sprintf("Can't connect: %v", err))
}
}
return swarm.NewSwarm(ctx, client, bzzconfig, swapEnabled, syncEnabled, cors)
}
if err := stack.Register(boot); err != nil {
- utils.Fatalf("Failed to register the Swarm service: %v", err)
+ log.Crit(fmt.Sprintf("Failed to register the Swarm service: %v", err))
}
}
@@ -339,11 +338,11 @@ func getAccount(ctx *cli.Context, stack *node.Node) *ecdsa.PrivateKey {
keyid := ctx.GlobalString(SwarmAccountFlag.Name)
if keyid == "" {
- utils.Fatalf("Option %q is required", SwarmAccountFlag.Name)
+ log.Crit(fmt.Sprintf("Option %q is required", SwarmAccountFlag.Name))
}
// Try to load the arg as a hex key file.
if key, err := crypto.LoadECDSA(keyid); err == nil {
- glog.V(logger.Info).Infof("swarm account key loaded: %#x", crypto.PubkeyToAddress(key.PublicKey))
+ log.Info(fmt.Sprintf("swarm account key loaded: %#x", crypto.PubkeyToAddress(key.PublicKey)))
return key
}
// Otherwise try getting it from the keystore.
@@ -365,14 +364,14 @@ func decryptStoreAccount(ks *keystore.KeyStore, account string) *ecdsa.PrivateKe
err = fmt.Errorf("index %d higher than number of accounts %d", ix, len(accounts))
}
} else {
- utils.Fatalf("Can't find swarm account key %s", account)
+ log.Crit(fmt.Sprintf("Can't find swarm account key %s", account))
}
if err != nil {
- utils.Fatalf("Can't find swarm account key: %v", err)
+ log.Crit(fmt.Sprintf("Can't find swarm account key: %v", err))
}
keyjson, err := ioutil.ReadFile(a.URL.Path)
if err != nil {
- utils.Fatalf("Can't load swarm account key: %v", err)
+ log.Crit(fmt.Sprintf("Can't load swarm account key: %v", err))
}
for i := 1; i <= 3; i++ {
passphrase := promptPassphrase(fmt.Sprintf("Unlocking swarm account %s [%d/3]", a.Address.Hex(), i))
@@ -381,7 +380,7 @@ func decryptStoreAccount(ks *keystore.KeyStore, account string) *ecdsa.PrivateKe
return key.PrivateKey
}
}
- utils.Fatalf("Can't decrypt swarm account key")
+ log.Crit(fmt.Sprintf("Can't decrypt swarm account key"))
return nil
}
@@ -391,7 +390,7 @@ func promptPassphrase(prompt string) string {
}
password, err := console.Stdin.PromptPassword("Passphrase: ")
if err != nil {
- utils.Fatalf("Failed to read passphrase: %v", err)
+ log.Crit(fmt.Sprintf("Failed to read passphrase: %v", err))
}
return password
}
@@ -400,7 +399,7 @@ func injectBootnodes(srv *p2p.Server, nodes []string) {
for _, url := range nodes {
n, err := discover.ParseNode(url)
if err != nil {
- glog.Errorf("invalid bootnode %q", err)
+ log.Error(fmt.Sprintf("invalid bootnode %q", err))
continue
}
srv.AddPeer(n)
diff --git a/cmd/swarm/manifest.go b/cmd/swarm/manifest.go
index 0de0d69bb..f64792689 100644
--- a/cmd/swarm/manifest.go
+++ b/cmd/swarm/manifest.go
@@ -18,13 +18,14 @@
package main
import (
- "gopkg.in/urfave/cli.v1"
+ "encoding/json"
+ "fmt"
"log"
"mime"
"path/filepath"
"strings"
- "fmt"
- "encoding/json"
+
+ "gopkg.in/urfave/cli.v1"
)
func add(ctx *cli.Context) {
@@ -35,23 +36,22 @@ func add(ctx *cli.Context) {
}
var (
- mhash = args[0]
- path = args[1]
- hash = args[2]
+ mhash = args[0]
+ path = args[1]
+ hash = args[2]
- ctype string
+ ctype string
wantManifest = ctx.GlobalBoolT(SwarmWantManifestFlag.Name)
- mroot manifest
+ mroot manifest
)
-
if len(args) > 3 {
ctype = args[3]
} else {
ctype = mime.TypeByExtension(filepath.Ext(path))
}
- newManifest := addEntryToManifest (ctx, mhash, path, hash, ctype)
+ newManifest := addEntryToManifest(ctx, mhash, path, hash, ctype)
fmt.Println(newManifest)
if !wantManifest {
@@ -70,13 +70,13 @@ func update(ctx *cli.Context) {
}
var (
- mhash = args[0]
- path = args[1]
- hash = args[2]
+ mhash = args[0]
+ path = args[1]
+ hash = args[2]
- ctype string
+ ctype string
wantManifest = ctx.GlobalBoolT(SwarmWantManifestFlag.Name)
- mroot manifest
+ mroot manifest
)
if len(args) > 3 {
ctype = args[3]
@@ -84,7 +84,7 @@ func update(ctx *cli.Context) {
ctype = mime.TypeByExtension(filepath.Ext(path))
}
- newManifest := updateEntryInManifest (ctx, mhash, path, hash, ctype)
+ newManifest := updateEntryInManifest(ctx, mhash, path, hash, ctype)
fmt.Println(newManifest)
if !wantManifest {
@@ -102,14 +102,14 @@ func remove(ctx *cli.Context) {
}
var (
- mhash = args[0]
- path = args[1]
+ mhash = args[0]
+ path = args[1]
wantManifest = ctx.GlobalBoolT(SwarmWantManifestFlag.Name)
- mroot manifest
+ mroot manifest
)
- newManifest := removeEntryFromManifest (ctx, mhash, path)
+ newManifest := removeEntryFromManifest(ctx, mhash, path)
fmt.Println(newManifest)
if !wantManifest {
@@ -120,15 +120,15 @@ func remove(ctx *cli.Context) {
}
}
-func addEntryToManifest(ctx *cli.Context, mhash , path, hash , ctype string) string {
+func addEntryToManifest(ctx *cli.Context, mhash, path, hash, ctype string) string {
var (
- bzzapi = strings.TrimRight(ctx.GlobalString(SwarmApiFlag.Name), "/")
- client = &client{api: bzzapi}
+ bzzapi = strings.TrimRight(ctx.GlobalString(SwarmApiFlag.Name), "/")
+ client = &client{api: bzzapi}
longestPathEntry = manifestEntry{
Path: "",
Hash: "",
- ContentType: "",
+ ContentType: "",
}
)
@@ -143,12 +143,11 @@ func addEntryToManifest(ctx *cli.Context, mhash , path, hash , ctype string) st
log.Fatalln("hash to add is not present:", err)
}
-
// See if we path is in this Manifest or do we have to dig deeper
for _, entry := range mroot.Entries {
if path == entry.Path {
log.Fatal(path, "Already present, not adding anything")
- }else {
+ } else {
if entry.ContentType == "application/bzz-manifest+json" {
prfxlen := strings.HasPrefix(path, entry.Path)
if prfxlen && len(path) > len(longestPathEntry.Path) {
@@ -161,7 +160,7 @@ func addEntryToManifest(ctx *cli.Context, mhash , path, hash , ctype string) st
if longestPathEntry.Path != "" {
// Load the child Manifest add the entry there
newPath := path[len(longestPathEntry.Path):]
- newHash := addEntryToManifest (ctx, longestPathEntry.Hash, newPath, hash, ctype)
+ newHash := addEntryToManifest(ctx, longestPathEntry.Hash, newPath, hash, ctype)
// Replace the hash for parent Manifests
newMRoot := manifest{}
@@ -182,31 +181,28 @@ func addEntryToManifest(ctx *cli.Context, mhash , path, hash , ctype string) st
mroot.Entries = append(mroot.Entries, newEntry)
}
-
newManifestHash, err := client.uploadManifest(mroot)
if err != nil {
log.Fatalln("manifest upload failed:", err)
}
return newManifestHash
-
-
}
-func updateEntryInManifest(ctx *cli.Context, mhash , path, hash , ctype string) string {
+func updateEntryInManifest(ctx *cli.Context, mhash, path, hash, ctype string) string {
var (
- bzzapi = strings.TrimRight(ctx.GlobalString(SwarmApiFlag.Name), "/")
- client = &client{api: bzzapi}
+ bzzapi = strings.TrimRight(ctx.GlobalString(SwarmApiFlag.Name), "/")
+ client = &client{api: bzzapi}
newEntry = manifestEntry{
Path: "",
Hash: "",
- ContentType: "",
+ ContentType: "",
}
longestPathEntry = manifestEntry{
Path: "",
Hash: "",
- ContentType: "",
+ ContentType: "",
}
)
@@ -217,12 +213,11 @@ func updateEntryInManifest(ctx *cli.Context, mhash , path, hash , ctype string)
//TODO: check if the "hash" with which to update is valid and present in swarm
-
// See if we path is in this Manifest or do we have to dig deeper
for _, entry := range mroot.Entries {
if path == entry.Path {
newEntry = entry
- }else {
+ } else {
if entry.ContentType == "application/bzz-manifest+json" {
prfxlen := strings.HasPrefix(path, entry.Path)
if prfxlen && len(path) > len(longestPathEntry.Path) {
@@ -239,7 +234,7 @@ func updateEntryInManifest(ctx *cli.Context, mhash , path, hash , ctype string)
if longestPathEntry.Path != "" {
// Load the child Manifest add the entry there
newPath := path[len(longestPathEntry.Path):]
- newHash := updateEntryInManifest (ctx, longestPathEntry.Hash, newPath, hash, ctype)
+ newHash := updateEntryInManifest(ctx, longestPathEntry.Hash, newPath, hash, ctype)
// Replace the hash for parent Manifests
newMRoot := manifest{}
@@ -271,7 +266,6 @@ func updateEntryInManifest(ctx *cli.Context, mhash , path, hash , ctype string)
mroot = newMRoot
}
-
newManifestHash, err := client.uploadManifest(mroot)
if err != nil {
log.Fatalln("manifest upload failed:", err)
@@ -279,20 +273,20 @@ func updateEntryInManifest(ctx *cli.Context, mhash , path, hash , ctype string)
return newManifestHash
}
-func removeEntryFromManifest(ctx *cli.Context, mhash , path string) string {
+func removeEntryFromManifest(ctx *cli.Context, mhash, path string) string {
var (
- bzzapi = strings.TrimRight(ctx.GlobalString(SwarmApiFlag.Name), "/")
- client = &client{api: bzzapi}
+ bzzapi = strings.TrimRight(ctx.GlobalString(SwarmApiFlag.Name), "/")
+ client = &client{api: bzzapi}
entryToRemove = manifestEntry{
Path: "",
Hash: "",
- ContentType: "",
+ ContentType: "",
}
longestPathEntry = manifestEntry{
Path: "",
Hash: "",
- ContentType: "",
+ ContentType: "",
}
)
@@ -301,13 +295,11 @@ func removeEntryFromManifest(ctx *cli.Context, mhash , path string) string {
log.Fatalln("manifest download failed:", err)
}
-
-
// See if we path is in this Manifest or do we have to dig deeper
for _, entry := range mroot.Entries {
if path == entry.Path {
entryToRemove = entry
- }else {
+ } else {
if entry.ContentType == "application/bzz-manifest+json" {
prfxlen := strings.HasPrefix(path, entry.Path)
if prfxlen && len(path) > len(longestPathEntry.Path) {
@@ -324,7 +316,7 @@ func removeEntryFromManifest(ctx *cli.Context, mhash , path string) string {
if longestPathEntry.Path != "" {
// Load the child Manifest remove the entry there
newPath := path[len(longestPathEntry.Path):]
- newHash := removeEntryFromManifest (ctx, longestPathEntry.Hash, newPath)
+ newHash := removeEntryFromManifest(ctx, longestPathEntry.Hash, newPath)
// Replace the hash for parent Manifests
newMRoot := manifest{}
@@ -348,13 +340,10 @@ func removeEntryFromManifest(ctx *cli.Context, mhash , path string) string {
mroot = newMRoot
}
-
newManifestHash, err := client.uploadManifest(mroot)
if err != nil {
log.Fatalln("manifest upload failed:", err)
}
return newManifestHash
-
}
-
diff --git a/cmd/swarm/upload.go b/cmd/swarm/upload.go
index 871713b2d..9f3a2abe0 100644
--- a/cmd/swarm/upload.go
+++ b/cmd/swarm/upload.go
@@ -233,7 +233,7 @@ func (c *client) postRaw(mimetype string, size int64, body io.ReadCloser) (strin
func (c *client) downloadManifest(mhash string) (manifest, error) {
mroot := manifest{}
- req, err := http.NewRequest("GET", c.api + "/bzzr:/" + mhash, nil)
+ req, err := http.NewRequest("GET", c.api+"/bzzr:/"+mhash, nil)
if err != nil {
return mroot, err
}
@@ -254,4 +254,4 @@ func (c *client) downloadManifest(mhash string) (manifest, error) {
return mroot, fmt.Errorf("Manifest %v is malformed: %v", mhash, err)
}
return mroot, err
-} \ No newline at end of file
+}
diff --git a/cmd/utils/cmd.go b/cmd/utils/cmd.go
index 8666f3775..e288f8bd2 100644
--- a/cmd/utils/cmd.go
+++ b/cmd/utils/cmd.go
@@ -31,8 +31,7 @@ import (
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/types"
"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/node"
"github.com/ethereum/go-ethereum/rlp"
)
@@ -72,19 +71,19 @@ func Fatalf(format string, args ...interface{}) {
func StartNode(stack *node.Node) {
if err := stack.Start(); err != nil {
- Fatalf("Error starting protocol stack: %v", err)
+ log.Crit(fmt.Sprintf("Error starting protocol stack: %v", err))
}
go func() {
sigc := make(chan os.Signal, 1)
signal.Notify(sigc, os.Interrupt)
defer signal.Stop(sigc)
<-sigc
- glog.V(logger.Info).Infoln("Got interrupt, shutting down...")
+ log.Info(fmt.Sprint("Got interrupt, shutting down..."))
go stack.Stop()
for i := 10; i > 0; i-- {
<-sigc
if i > 1 {
- glog.V(logger.Info).Infof("Already shutting down, interrupt %d more times for panic.", i-1)
+ log.Info(fmt.Sprintf("Already shutting down, interrupt %d more times for panic.", i-1))
}
}
debug.Exit() // ensure trace and CPU profile data is flushed.
@@ -115,7 +114,7 @@ func ImportChain(chain *core.BlockChain, fn string) error {
defer close(interrupt)
go func() {
if _, ok := <-interrupt; ok {
- glog.Info("caught interrupt during import, will stop at next batch")
+ log.Info(fmt.Sprint("caught interrupt during import, will stop at next batch"))
}
close(stop)
}()
@@ -128,7 +127,7 @@ func ImportChain(chain *core.BlockChain, fn string) error {
}
}
- glog.Infoln("Importing blockchain ", fn)
+ log.Info(fmt.Sprint("Importing blockchain ", fn))
fh, err := os.Open(fn)
if err != nil {
return err
@@ -176,8 +175,8 @@ func ImportChain(chain *core.BlockChain, fn string) error {
return fmt.Errorf("interrupted")
}
if hasAllBlocks(chain, blocks[:i]) {
- glog.Infof("skipping batch %d, all blocks present [%x / %x]",
- batch, blocks[0].Hash().Bytes()[:4], blocks[i-1].Hash().Bytes()[:4])
+ log.Info(fmt.Sprintf("skipping batch %d, all blocks present [%x / %x]",
+ batch, blocks[0].Hash().Bytes()[:4], blocks[i-1].Hash().Bytes()[:4]))
continue
}
@@ -198,7 +197,7 @@ func hasAllBlocks(chain *core.BlockChain, bs []*types.Block) bool {
}
func ExportChain(blockchain *core.BlockChain, fn string) error {
- glog.Infoln("Exporting blockchain to ", fn)
+ log.Info(fmt.Sprint("Exporting blockchain to ", fn))
fh, err := os.OpenFile(fn, os.O_CREATE|os.O_WRONLY|os.O_TRUNC, os.ModePerm)
if err != nil {
return err
@@ -214,13 +213,13 @@ func ExportChain(blockchain *core.BlockChain, fn string) error {
if err := blockchain.Export(writer); err != nil {
return err
}
- glog.Infoln("Exported blockchain to ", fn)
+ log.Info(fmt.Sprint("Exported blockchain to ", fn))
return nil
}
func ExportAppendChain(blockchain *core.BlockChain, fn string, first uint64, last uint64) error {
- glog.Infoln("Exporting blockchain to ", fn)
+ log.Info(fmt.Sprint("Exporting blockchain to ", fn))
// TODO verify mode perms
fh, err := os.OpenFile(fn, os.O_CREATE|os.O_APPEND|os.O_WRONLY, os.ModePerm)
if err != nil {
@@ -237,6 +236,6 @@ func ExportAppendChain(blockchain *core.BlockChain, fn string, first uint64, las
if err := blockchain.ExportN(writer, first, last); err != nil {
return err
}
- glog.Infoln("Exported blockchain to ", fn)
+ log.Info(fmt.Sprint("Exported blockchain to ", fn))
return nil
}
diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go
index 92eb05e32..55713c15c 100644
--- a/cmd/utils/flags.go
+++ b/cmd/utils/flags.go
@@ -41,8 +41,7 @@ import (
"github.com/ethereum/go-ethereum/ethstats"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/les"
- "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/p2p/discover"
@@ -426,7 +425,7 @@ func MakeDataDir(ctx *cli.Context) string {
}
return path
}
- Fatalf("Cannot determine default data directory, please set manually (--datadir)")
+ log.Crit(fmt.Sprintf("Cannot determine default data directory, please set manually (--datadir)"))
return ""
}
@@ -452,16 +451,16 @@ func MakeNodeKey(ctx *cli.Context) *ecdsa.PrivateKey {
)
switch {
case file != "" && hex != "":
- Fatalf("Options %q and %q are mutually exclusive", NodeKeyFileFlag.Name, NodeKeyHexFlag.Name)
+ log.Crit(fmt.Sprintf("Options %q and %q are mutually exclusive", NodeKeyFileFlag.Name, NodeKeyHexFlag.Name))
case file != "":
if key, err = crypto.LoadECDSA(file); err != nil {
- Fatalf("Option %q: %v", NodeKeyFileFlag.Name, err)
+ log.Crit(fmt.Sprintf("Option %q: %v", NodeKeyFileFlag.Name, err))
}
case hex != "":
if key, err = crypto.HexToECDSA(hex); err != nil {
- Fatalf("Option %q: %v", NodeKeyHexFlag.Name, err)
+ log.Crit(fmt.Sprintf("Option %q: %v", NodeKeyHexFlag.Name, err))
}
}
return key
@@ -493,7 +492,7 @@ func MakeBootstrapNodes(ctx *cli.Context) []*discover.Node {
for _, url := range urls {
node, err := discover.ParseNode(url)
if err != nil {
- glog.V(logger.Error).Infof("Bootstrap URL %s: %v\n", url, err)
+ log.Error(fmt.Sprintf("Bootstrap URL %s: %v\n", url, err))
continue
}
bootnodes = append(bootnodes, node)
@@ -513,7 +512,7 @@ func MakeBootstrapNodesV5(ctx *cli.Context) []*discv5.Node {
for _, url := range urls {
node, err := discv5.ParseNode(url)
if err != nil {
- glog.V(logger.Error).Infof("Bootstrap URL %s: %v\n", url, err)
+ log.Error(fmt.Sprintf("Bootstrap URL %s: %v\n", url, err))
continue
}
bootnodes = append(bootnodes, node)
@@ -537,7 +536,7 @@ func MakeDiscoveryV5Address(ctx *cli.Context) string {
func MakeNAT(ctx *cli.Context) nat.Interface {
natif, err := nat.Parse(ctx.GlobalString(NATFlag.Name))
if err != nil {
- Fatalf("Option %s: %v", NATFlag.Name, err)
+ log.Crit(fmt.Sprintf("Option %s: %v", NATFlag.Name, err))
}
return natif
}
@@ -574,11 +573,11 @@ func MakeWSRpcHost(ctx *cli.Context) string {
// for Geth and returns half of the allowance to assign to the database.
func MakeDatabaseHandles() int {
if err := raiseFdLimit(2048); err != nil {
- Fatalf("Failed to raise file descriptor allowance: %v", err)
+ log.Crit(fmt.Sprintf("Failed to raise file descriptor allowance: %v", err))
}
limit, err := getFdLimit()
if err != nil {
- Fatalf("Failed to retrieve file descriptor allowance: %v", err)
+ log.Crit(fmt.Sprintf("Failed to retrieve file descriptor allowance: %v", err))
}
if limit > 2048 { // cap database file descriptors even if more is available
limit = 2048
@@ -610,7 +609,7 @@ func MakeAddress(ks *keystore.KeyStore, account string) (accounts.Account, error
func MakeEtherbase(ks *keystore.KeyStore, ctx *cli.Context) common.Address {
accounts := ks.Accounts()
if !ctx.GlobalIsSet(EtherbaseFlag.Name) && len(accounts) == 0 {
- glog.V(logger.Error).Infoln("WARNING: No etherbase set and no accounts found as default")
+ log.Error(fmt.Sprint("WARNING: No etherbase set and no accounts found as default"))
return common.Address{}
}
etherbase := ctx.GlobalString(EtherbaseFlag.Name)
@@ -620,7 +619,7 @@ func MakeEtherbase(ks *keystore.KeyStore, ctx *cli.Context) common.Address {
// If the specified etherbase is a valid address, return it
account, err := MakeAddress(ks, etherbase)
if err != nil {
- Fatalf("Option %q: %v", EtherbaseFlag.Name, err)
+ log.Crit(fmt.Sprintf("Option %q: %v", EtherbaseFlag.Name, err))
}
return account.Address
}
@@ -642,7 +641,7 @@ func MakePasswordList(ctx *cli.Context) []string {
}
text, err := ioutil.ReadFile(path)
if err != nil {
- Fatalf("Failed to read password file: %v", err)
+ log.Crit(fmt.Sprintf("Failed to read password file: %v", err))
}
lines := strings.Split(string(text), "\n")
// Sanitise DOS line endings.
@@ -701,14 +700,14 @@ func MakeNode(ctx *cli.Context, name, gitCommit string) *node.Node {
if netrestrict := ctx.GlobalString(NetrestrictFlag.Name); netrestrict != "" {
list, err := netutil.ParseNetlist(netrestrict)
if err != nil {
- Fatalf("Option %q: %v", NetrestrictFlag.Name, err)
+ log.Crit(fmt.Sprintf("Option %q: %v", NetrestrictFlag.Name, err))
}
config.NetRestrict = list
}
stack, err := node.New(config)
if err != nil {
- Fatalf("Failed to create the protocol stack: %v", err)
+ log.Crit(fmt.Sprintf("Failed to create the protocol stack: %v", err))
}
return stack
}
@@ -724,7 +723,7 @@ func RegisterEthService(ctx *cli.Context, stack *node.Node, extra []byte) {
}
}
if networks > 1 {
- Fatalf("The %v flags are mutually exclusive", netFlags)
+ log.Crit(fmt.Sprintf("The %v flags are mutually exclusive", netFlags))
}
ks := stack.AccountManager().Backends(keystore.KeyStoreType)[0].(*keystore.KeyStore)
@@ -778,7 +777,7 @@ func RegisterEthService(ctx *cli.Context, stack *node.Node, extra []byte) {
if err := stack.Register(func(ctx *node.ServiceContext) (node.Service, error) {
return les.New(ctx, ethConf)
}); err != nil {
- Fatalf("Failed to register the Ethereum light node service: %v", err)
+ log.Crit(fmt.Sprintf("Failed to register the Ethereum light node service: %v", err))
}
} else {
if err := stack.Register(func(ctx *node.ServiceContext) (node.Service, error) {
@@ -789,7 +788,7 @@ func RegisterEthService(ctx *cli.Context, stack *node.Node, extra []byte) {
}
return fullNode, err
}); err != nil {
- Fatalf("Failed to register the Ethereum full node service: %v", err)
+ log.Crit(fmt.Sprintf("Failed to register the Ethereum full node service: %v", err))
}
}
}
@@ -797,7 +796,7 @@ func RegisterEthService(ctx *cli.Context, stack *node.Node, extra []byte) {
// RegisterShhService configures Whisper and adds it to the given node.
func RegisterShhService(stack *node.Node) {
if err := stack.Register(func(*node.ServiceContext) (node.Service, error) { return whisper.New(), nil }); err != nil {
- Fatalf("Failed to register the Whisper service: %v", err)
+ log.Crit(fmt.Sprintf("Failed to register the Whisper service: %v", err))
}
}
@@ -814,7 +813,7 @@ func RegisterEthStatsService(stack *node.Node, url string) {
return ethstats.New(url, ethServ, lesServ)
}); err != nil {
- Fatalf("Failed to register the Ethereum Stats service: %v", err)
+ log.Crit(fmt.Sprintf("Failed to register the Ethereum Stats service: %v", err))
}
}
@@ -845,7 +844,7 @@ func MakeChainConfigFromDb(ctx *cli.Context, db ethdb.Database) *params.ChainCon
case core.ChainConfigNotFoundErr:
// No configs found, use empty, will populate below
default:
- Fatalf("Could not make chain configuration: %v", err)
+ log.Crit(fmt.Sprintf("Could not make chain configuration: %v", err))
}
}
// set chain id in case it's zero.
@@ -900,7 +899,7 @@ func MakeChainDatabase(ctx *cli.Context, stack *node.Node) ethdb.Database {
chainDb, err := stack.OpenDatabase(name, cache, handles)
if err != nil {
- Fatalf("Could not open database: %v", err)
+ log.Crit(fmt.Sprintf("Could not open database: %v", err))
}
return chainDb
}
@@ -913,7 +912,7 @@ func MakeChain(ctx *cli.Context, stack *node.Node) (chain *core.BlockChain, chai
if ctx.GlobalBool(TestNetFlag.Name) {
_, err := core.WriteTestNetGenesisBlock(chainDb)
if err != nil {
- glog.Fatalln(err)
+ log.Crit(fmt.Sprint(err))
}
}
@@ -925,7 +924,7 @@ func MakeChain(ctx *cli.Context, stack *node.Node) (chain *core.BlockChain, chai
}
chain, err = core.NewBlockChain(chainDb, chainConfig, pow, new(event.TypeMux), vm.Config{EnablePreimageRecording: ctx.GlobalBool(VMEnableDebugFlag.Name)})
if err != nil {
- Fatalf("Could not start chainmanager: %v", err)
+ log.Crit(fmt.Sprintf("Could not start chainmanager: %v", err))
}
return chain, chainDb
}
diff --git a/cmd/wnode/main.go b/cmd/wnode/main.go
index d002497fb..eb0dd2511 100644
--- a/cmd/wnode/main.go
+++ b/cmd/wnode/main.go
@@ -36,8 +36,7 @@ import (
"github.com/ethereum/go-ethereum/common"
"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"
"github.com/ethereum/go-ethereum/p2p"
"github.com/ethereum/go-ethereum/p2p/discover"
"github.com/ethereum/go-ethereum/p2p/nat"
@@ -82,7 +81,7 @@ var (
testMode = flag.Bool("t", false, "use of predefined parameters for diagnostics")
generateKey = flag.Bool("k", false, "generate and show the private key")
- argVerbosity = flag.Int("verbosity", logger.Warn, "log verbosity level")
+ argVerbosity = flag.Int("verbosity", int(log.LvlWarn), "log verbosity level")
argTTL = flag.Uint("ttl", 30, "time-to-live for messages in seconds")
argWorkTime = flag.Uint("work", 5, "work time in seconds")
argPoW = flag.Float64("pow", whisper.MinimumPoW, "PoW for normal messages in float format (e.g. 2.7)")
@@ -109,7 +108,7 @@ func processArgs() {
var err error
nodeid, err = crypto.LoadECDSA(*argIDFile)
if err != nil {
- utils.Fatalf("Failed to load file [%s]: %s.", *argIDFile, err)
+ log.Crit(fmt.Sprintf("Failed to load file [%s]: %s.", *argIDFile, err))
}
}
@@ -123,7 +122,7 @@ func processArgs() {
if len(*argTopic) > 0 {
x, err := hex.DecodeString(*argTopic)
if err != nil {
- utils.Fatalf("Failed to parse the topic: %s", err)
+ log.Crit(fmt.Sprintf("Failed to parse the topic: %s", err))
}
topic = whisper.BytesToTopic(x)
}
@@ -131,7 +130,7 @@ func processArgs() {
if *asymmetricMode && len(*argPub) > 0 {
pub = crypto.ToECDSAPub(common.FromHex(*argPub))
if !isKeyValid(pub) {
- utils.Fatalf("invalid public key")
+ log.Crit(fmt.Sprintf("invalid public key"))
}
}
@@ -153,8 +152,7 @@ func echo() {
}
func initialize() {
- glog.SetV(*argVerbosity)
- glog.SetToStderr(true)
+ log.Root().SetHandler(log.LvlFilterHandler(log.Lvl(*argVerbosity), log.StreamHandler(os.Stderr, log.TerminalFormat())))
done = make(chan struct{})
var peers []*discover.Node
@@ -163,7 +161,7 @@ func initialize() {
if *generateKey {
key, err := crypto.GenerateKey()
if err != nil {
- utils.Fatalf("Failed to generate private key: %s", err)
+ log.Crit(fmt.Sprintf("Failed to generate private key: %s", err))
}
k := hex.EncodeToString(crypto.FromECDSA(key))
fmt.Printf("Random private key: %s \n", k)
@@ -191,7 +189,7 @@ func initialize() {
if len(msPassword) == 0 {
msPassword, err = console.Stdin.PromptPassword("Please enter the Mail Server password: ")
if err != nil {
- utils.Fatalf("Failed to read Mail Server password: %s", err)
+ log.Crit(fmt.Sprintf("Failed to read Mail Server password: %s", err))
}
}
shh = whisper.New()
@@ -229,7 +227,7 @@ func initialize() {
func startServer() {
err := server.Start()
if err != nil {
- utils.Fatalf("Failed to start Whisper peer: %s.", err)
+ log.Crit(fmt.Sprintf("Failed to start Whisper peer: %s.", err))
}
fmt.Printf("my public key: %s \n", common.ToHex(crypto.FromECDSAPub(&asymKey.PublicKey)))
@@ -267,7 +265,7 @@ func configureNode() {
s := scanLine("Please enter the peer's public key: ")
pub = crypto.ToECDSAPub(common.FromHex(s))
if !isKeyValid(pub) {
- utils.Fatalf("Error: invalid public key")
+ log.Crit(fmt.Sprintf("Error: invalid public key"))
}
}
}
@@ -277,7 +275,7 @@ func configureNode() {
if len(msPassword) == 0 {
msPassword, err = console.Stdin.PromptPassword("Please enter the Mail Server password: ")
if err != nil {
- utils.Fatalf("Failed to read Mail Server password: %s", err)
+ log.Crit(fmt.Sprintf("Failed to read Mail Server password: %s", err))
}
}
}
@@ -286,7 +284,7 @@ func configureNode() {
if len(symPass) == 0 {
symPass, err = console.Stdin.PromptPassword("Please enter the password: ")
if err != nil {
- utils.Fatalf("Failed to read passphrase: %v", err)
+ log.Crit(fmt.Sprintf("Failed to read passphrase: %v", err))
}
}
@@ -332,7 +330,7 @@ func waitForConnection(timeout bool) {
if timeout {
cnt++
if cnt > 1000 {
- utils.Fatalf("Timeout expired, failed to connect")
+ log.Crit(fmt.Sprintf("Timeout expired, failed to connect"))
}
}
}
@@ -384,7 +382,7 @@ func scanLine(prompt string) string {
}
txt, err := input.ReadString('\n')
if err != nil {
- utils.Fatalf("input error: %s", err)
+ log.Crit(fmt.Sprintf("input error: %s", err))
}
txt = strings.TrimRight(txt, "\n\r")
return txt
@@ -399,7 +397,7 @@ func scanUint(prompt string) uint32 {
s := scanLine(prompt)
i, err := strconv.Atoi(s)
if err != nil {
- utils.Fatalf("Fail to parse the lower time limit: %s", err)
+ log.Crit(fmt.Sprintf("Fail to parse the lower time limit: %s", err))
}
return uint32(i)
}
@@ -432,7 +430,7 @@ func sendMsg(payload []byte) {
func messageLoop() {
f := shh.GetFilter(filterID)
if f == nil {
- utils.Fatalf("filter is not installed")
+ log.Crit(fmt.Sprintf("filter is not installed"))
}
ticker := time.NewTicker(time.Millisecond * 50)
@@ -474,7 +472,7 @@ func requestExpiredMessagesLoop() {
err := shh.AddSymKey(mailserver.MailServerKeyName, []byte(msPassword))
if err != nil {
- utils.Fatalf("Failed to create symmetric key for mail request: %s", err)
+ log.Crit(fmt.Sprintf("Failed to create symmetric key for mail request: %s", err))
}
key = shh.GetSymKey(mailserver.MailServerKeyName)
peerID = extractIdFromEnode(*argEnode)
@@ -487,7 +485,7 @@ func requestExpiredMessagesLoop() {
if len(t) >= whisper.TopicLength*2 {
x, err := hex.DecodeString(t)
if err != nil {
- utils.Fatalf("Failed to parse the topic: %s", err)
+ log.Crit(fmt.Sprintf("Failed to parse the topic: %s", err))
}
xt = whisper.BytesToTopic(x)
}
@@ -513,12 +511,12 @@ func requestExpiredMessagesLoop() {
msg := whisper.NewSentMessage(&params)
env, err := msg.Wrap(&params)
if err != nil {
- utils.Fatalf("Wrap failed: %s", err)
+ log.Crit(fmt.Sprintf("Wrap failed: %s", err))
}
err = shh.RequestHistoricMessages(peerID, env)
if err != nil {
- utils.Fatalf("Failed to send P2P message: %s", err)
+ log.Crit(fmt.Sprintf("Failed to send P2P message: %s", err))
}
time.Sleep(time.Second * 5)
@@ -528,7 +526,7 @@ func requestExpiredMessagesLoop() {
func extractIdFromEnode(s string) []byte {
n, err := discover.ParseNode(s)
if err != nil {
- utils.Fatalf("Failed to parse enode: %s", err)
+ log.Crit(fmt.Sprintf("Failed to parse enode: %s", err))
return nil
}
return n.ID[:]