diff options
author | Péter Szilágyi <peterke@gmail.com> | 2017-02-22 22:58:00 +0800 |
---|---|---|
committer | Péter Szilágyi <peterke@gmail.com> | 2017-02-23 18:16:46 +0800 |
commit | 23a5d64fd059bb8bdf02781608a15b8b1bdbdfd2 (patch) | |
tree | 143cd04a9fe002b25c146e7c0b5aacfbe62092eb /accounts/keystore | |
parent | 61e6bb12478740d614c8effd330f881f962b7b84 (diff) | |
download | dexon-23a5d64fd059bb8bdf02781608a15b8b1bdbdfd2.tar.gz dexon-23a5d64fd059bb8bdf02781608a15b8b1bdbdfd2.tar.zst dexon-23a5d64fd059bb8bdf02781608a15b8b1bdbdfd2.zip |
accounts, cmd: port packages over to the new logging system
Diffstat (limited to 'accounts/keystore')
-rw-r--r-- | accounts/keystore/account_cache.go | 14 | ||||
-rw-r--r-- | accounts/keystore/watch.go | 12 |
2 files changed, 14 insertions, 12 deletions
diff --git a/accounts/keystore/account_cache.go b/accounts/keystore/account_cache.go index 11100ebc1..866f8ae7b 100644 --- a/accounts/keystore/account_cache.go +++ b/accounts/keystore/account_cache.go @@ -210,7 +210,7 @@ func (ac *accountCache) close() { func (ac *accountCache) reload() { accounts, err := ac.scan() if err != nil { - log.Debug(fmt.Sprintf("can't load keys: %v", err)) + log.Debug("Failed to reload keystore contents", "error", err) } ac.all = accounts sort.Sort(ac.all) @@ -224,7 +224,7 @@ func (ac *accountCache) reload() { case ac.notify <- struct{}{}: default: } - log.Debug(fmt.Sprintf("reloaded keys, cache has %d accounts", len(ac.all))) + log.Debug("Reloaded keystore contents", "accounts", len(ac.all)) } func (ac *accountCache) scan() ([]accounts.Account, error) { @@ -243,12 +243,14 @@ func (ac *accountCache) scan() ([]accounts.Account, error) { for _, fi := range files { path := filepath.Join(ac.keydir, fi.Name()) if skipKeyFile(fi) { - log.Trace(fmt.Sprintf("ignoring file %s", path)) + log.Trace("Ignoring file on account scan", "path", path) continue } + logger := log.New("path", path) + fd, err := os.Open(path) if err != nil { - log.Trace(fmt.Sprint(err)) + logger.Trace("Failed to open keystore file", "error", err) continue } buf.Reset(fd) @@ -258,9 +260,9 @@ func (ac *accountCache) scan() ([]accounts.Account, error) { addr := common.HexToAddress(keyJSON.Address) switch { case err != nil: - log.Debug(fmt.Sprintf("can't decode key %s: %v", path, err)) + logger.Debug("Failed to decode keystore key", "error", err) case (addr == common.Address{}): - log.Debug(fmt.Sprintf("can't decode key %s: missing or zero address", path)) + logger.Debug("Failed to decode keystore key", "error", "missing or zero address") 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 ff95a7cdc..ae97805be 100644 --- a/accounts/keystore/watch.go +++ b/accounts/keystore/watch.go @@ -19,7 +19,6 @@ package keystore import ( - "fmt" "time" "github.com/ethereum/go-ethereum/log" @@ -64,15 +63,16 @@ func (w *watcher) loop() { w.starting = false w.ac.mu.Unlock() }() + logger := log.New("path", w.ac.keydir) - err := notify.Watch(w.ac.keydir, w.ev, notify.All) - if err != nil { - log.Trace(fmt.Sprintf("can't watch %s: %v", w.ac.keydir, err)) + if err := notify.Watch(w.ac.keydir, w.ev, notify.All); err != nil { + logger.Trace("Failed to watch keystore folder", "error", err) return } defer notify.Stop(w.ev) - log.Trace(fmt.Sprintf("now watching %s", w.ac.keydir)) - defer log.Trace(fmt.Sprintf("no longer watching %s", w.ac.keydir)) + + logger.Trace("Started watching keystore folder") + defer logger.Trace("Stopped watching keystore folder") w.ac.mu.Lock() w.running = true |