diff options
author | Péter Szilágyi <peterke@gmail.com> | 2017-02-22 20:10:07 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2017-02-23 18:16:44 +0800 |
commit | d4fd06c3dc6cd6d2dbd2bfebfee5bcb46a504851 (patch) | |
tree | 17c93170551d3eeabe2935de1765f157007f0dc2 /accounts | |
parent | 47af53f9aaf9aa7b12cd976eb150ccf3d64da6fd (diff) | |
download | dexon-d4fd06c3dc6cd6d2dbd2bfebfee5bcb46a504851.tar.gz dexon-d4fd06c3dc6cd6d2dbd2bfebfee5bcb46a504851.tar.zst dexon-d4fd06c3dc6cd6d2dbd2bfebfee5bcb46a504851.zip |
all: blidly swap out glog to our log15, logs need rework
Diffstat (limited to 'accounts')
-rw-r--r-- | accounts/abi/bind/util.go | 7 | ||||
-rw-r--r-- | accounts/keystore/account_cache.go | 17 | ||||
-rw-r--r-- | accounts/keystore/watch.go | 10 | ||||
-rw-r--r-- | accounts/usbwallet/ledger_wallet.go | 32 |
4 files changed, 30 insertions, 36 deletions
diff --git a/accounts/abi/bind/util.go b/accounts/abi/bind/util.go index bbb6d6a75..88234688e 100644 --- a/accounts/abi/bind/util.go +++ b/accounts/abi/bind/util.go @@ -22,8 +22,7 @@ import ( "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/logger" - "github.com/ethereum/go-ethereum/logger/glog" + "github.com/ethereum/go-ethereum/log" "golang.org/x/net/context" ) @@ -39,9 +38,9 @@ func WaitMined(ctx context.Context, b DeployBackend, tx *types.Transaction) (*ty return receipt, nil } if err != nil { - glog.V(logger.Detail).Infof("tx %x error: %v", loghash, err) + log.Trace(fmt.Sprintf("tx %x error: %v", loghash, err)) } else { - glog.V(logger.Detail).Infof("tx %x not yet mined...", loghash) + log.Trace(fmt.Sprintf("tx %x not yet mined...", loghash)) } // Wait for the next round. select { diff --git a/accounts/keystore/account_cache.go b/accounts/keystore/account_cache.go index 3fae3ef5b..11100ebc1 100644 --- a/accounts/keystore/account_cache.go +++ b/accounts/keystore/account_cache.go @@ -30,8 +30,7 @@ import ( "github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/common" - "github.com/ethereum/go-ethereum/logger" - "github.com/ethereum/go-ethereum/logger/glog" + "github.com/ethereum/go-ethereum/log" ) // Minimum amount of time between cache reloads. This limit applies if the platform does @@ -210,8 +209,8 @@ func (ac *accountCache) close() { // Callers must hold ac.mu. func (ac *accountCache) reload() { accounts, err := ac.scan() - if err != nil && glog.V(logger.Debug) { - glog.Errorf("can't load keys: %v", err) + if err != nil { + log.Debug(fmt.Sprintf("can't load keys: %v", err)) } ac.all = accounts sort.Sort(ac.all) @@ -225,7 +224,7 @@ func (ac *accountCache) reload() { case ac.notify <- struct{}{}: default: } - glog.V(logger.Debug).Infof("reloaded keys, cache has %d accounts", len(ac.all)) + log.Debug(fmt.Sprintf("reloaded keys, cache has %d accounts", len(ac.all))) } func (ac *accountCache) scan() ([]accounts.Account, error) { @@ -244,12 +243,12 @@ func (ac *accountCache) scan() ([]accounts.Account, error) { for _, fi := range files { path := filepath.Join(ac.keydir, fi.Name()) if skipKeyFile(fi) { - glog.V(logger.Detail).Infof("ignoring file %s", path) + log.Trace(fmt.Sprintf("ignoring file %s", path)) continue } fd, err := os.Open(path) if err != nil { - glog.V(logger.Detail).Infoln(err) + log.Trace(fmt.Sprint(err)) continue } buf.Reset(fd) @@ -259,9 +258,9 @@ func (ac *accountCache) scan() ([]accounts.Account, error) { addr := common.HexToAddress(keyJSON.Address) switch { case err != nil: - glog.V(logger.Debug).Infof("can't decode key %s: %v", path, err) + log.Debug(fmt.Sprintf("can't decode key %s: %v", path, err)) case (addr == common.Address{}): - glog.V(logger.Debug).Infof("can't decode key %s: missing or zero address", path) + log.Debug(fmt.Sprintf("can't decode key %s: missing or zero address", path)) default: addrs = append(addrs, accounts.Account{Address: addr, URL: accounts.URL{Scheme: KeyStoreScheme, Path: path}}) } diff --git a/accounts/keystore/watch.go b/accounts/keystore/watch.go index 0b4401255..ff95a7cdc 100644 --- a/accounts/keystore/watch.go +++ b/accounts/keystore/watch.go @@ -19,10 +19,10 @@ package keystore import ( + "fmt" "time" - "github.com/ethereum/go-ethereum/logger" - "github.com/ethereum/go-ethereum/logger/glog" + "github.com/ethereum/go-ethereum/log" "github.com/rjeczalik/notify" ) @@ -67,12 +67,12 @@ func (w *watcher) loop() { err := notify.Watch(w.ac.keydir, w.ev, notify.All) if err != nil { - glog.V(logger.Detail).Infof("can't watch %s: %v", w.ac.keydir, err) + log.Trace(fmt.Sprintf("can't watch %s: %v", w.ac.keydir, err)) return } defer notify.Stop(w.ev) - glog.V(logger.Detail).Infof("now watching %s", w.ac.keydir) - defer glog.V(logger.Detail).Infof("no longer watching %s", w.ac.keydir) + log.Trace(fmt.Sprintf("now watching %s", w.ac.keydir)) + defer log.Trace(fmt.Sprintf("no longer watching %s", w.ac.keydir)) w.ac.mu.Lock() w.running = true diff --git a/accounts/usbwallet/ledger_wallet.go b/accounts/usbwallet/ledger_wallet.go index 235086d1e..0dc53daf5 100644 --- a/accounts/usbwallet/ledger_wallet.go +++ b/accounts/usbwallet/ledger_wallet.go @@ -34,8 +34,7 @@ import ( "github.com/ethereum/go-ethereum/accounts" "github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/core/types" - "github.com/ethereum/go-ethereum/logger" - "github.com/ethereum/go-ethereum/logger/glog" + "github.com/ethereum/go-ethereum/log" "github.com/ethereum/go-ethereum/rlp" "github.com/karalabe/hid" "golang.org/x/net/context" @@ -220,8 +219,8 @@ func (w *ledgerWallet) Open(passphrase string) error { // - libusb on Windows doesn't support hotplug, so we can't detect USB unplugs // - communication timeout on the Ledger requires a device power cycle to fix func (w *ledgerWallet) heartbeat() { - glog.V(logger.Debug).Infof("%s health-check started", w.url.String()) - defer glog.V(logger.Debug).Infof("%s health-check stopped", w.url.String()) + log.Debug(fmt.Sprintf("%s health-check started", w.url.String())) + defer log.Debug(fmt.Sprintf("%s health-check stopped", w.url.String())) // Execute heartbeat checks until termination or error var ( @@ -260,7 +259,7 @@ func (w *ledgerWallet) heartbeat() { } // In case of error, wait for termination if err != nil { - glog.V(logger.Debug).Infof("%s health-check failed: %v", w.url.String(), err) + log.Debug(fmt.Sprintf("%s health-check failed: %v", w.url.String(), err)) errc = <-w.healthQuit } errc <- err @@ -348,8 +347,8 @@ func (w *ledgerWallet) Accounts() []accounts.Account { // selfDerive is an account derivation loop that upon request attempts to find // new non-zero accounts. func (w *ledgerWallet) selfDerive() { - glog.V(logger.Debug).Infof("%s self-derivation started", w.url.String()) - defer glog.V(logger.Debug).Infof("%s self-derivation stopped", w.url.String()) + log.Debug(fmt.Sprintf("%s self-derivation started", w.url.String())) + defer log.Debug(fmt.Sprintf("%s self-derivation stopped", w.url.String())) // Execute self-derivations until termination or error var ( @@ -394,7 +393,7 @@ func (w *ledgerWallet) selfDerive() { // Retrieve the next derived Ethereum account if nextAddr == (common.Address{}) { if nextAddr, err = w.ledgerDerive(nextPath); err != nil { - glog.V(logger.Warn).Infof("%s self-derivation failed: %v", w.url.String(), err) + log.Warn(fmt.Sprintf("%s self-derivation failed: %v", w.url.String(), err)) break } } @@ -405,12 +404,12 @@ func (w *ledgerWallet) selfDerive() { ) balance, err = w.deriveChain.BalanceAt(context, nextAddr, nil) if err != nil { - glog.V(logger.Warn).Infof("%s self-derivation balance retrieval failed: %v", w.url.String(), err) + log.Warn(fmt.Sprintf("%s self-derivation balance retrieval failed: %v", w.url.String(), err)) break } nonce, err = w.deriveChain.NonceAt(context, nextAddr, nil) if err != nil { - glog.V(logger.Warn).Infof("%s self-derivation nonce retrieval failed: %v", w.url.String(), err) + log.Warn(fmt.Sprintf("%s self-derivation nonce retrieval failed: %v", w.url.String(), err)) break } // If the next account is empty, stop self-derivation, but add it nonetheless @@ -430,7 +429,7 @@ func (w *ledgerWallet) selfDerive() { // Display a log message to the user for new (or previously empty accounts) if _, known := w.paths[nextAddr]; !known || (!empty && nextAddr == w.deriveNextAddr) { - glog.V(logger.Info).Infof("%s discovered %s (balance %22v, nonce %4d) at %s", w.url.String(), nextAddr.Hex(), balance, nonce, path) + log.Info(fmt.Sprintf("%s discovered %s (balance %22v, nonce %4d) at %s", w.url.String(), nextAddr.Hex(), balance, nonce, path)) } // Fetch the next potential account if !empty { @@ -469,7 +468,7 @@ func (w *ledgerWallet) selfDerive() { } // In case of error, wait for termination if err != nil { - glog.V(logger.Debug).Infof("%s self-derivation failed: %s", w.url.String(), err) + log.Debug(fmt.Sprintf("%s self-derivation failed: %s", w.url.String(), err)) errc = <-w.deriveQuit } errc <- err @@ -849,9 +848,7 @@ func (w *ledgerWallet) ledgerExchange(opcode ledgerOpcode, p1 ledgerParam1, p2 l apdu = nil } // Send over to the device - if glog.V(logger.Detail) { - glog.Infof("-> %s: %x", w.device.Path, chunk) - } + log.Trace("", "msg", log.Lazy{Fn: func() string { return fmt.Sprintf("-> %s: %x", w.device.Path, chunk) }}) if _, err := w.device.Write(chunk); err != nil { return nil, err } @@ -864,9 +861,8 @@ func (w *ledgerWallet) ledgerExchange(opcode ledgerOpcode, p1 ledgerParam1, p2 l if _, err := io.ReadFull(w.device, chunk); err != nil { return nil, err } - if glog.V(logger.Detail) { - glog.Infof("<- %s: %x", w.device.Path, chunk) - } + log.Trace("", "msg", log.Lazy{Fn: func() string { return fmt.Sprintf("<- %s: %x", w.device.Path, chunk) }}) + // Make sure the transport header matches if chunk[0] != 0x01 || chunk[1] != 0x01 || chunk[2] != 0x05 { return nil, errReplyInvalidHeader |