Skip to content

Commit d4fd06c

Browse files
committed
all: blidly swap out glog to our log15, logs need rework
1 parent 47af53f commit d4fd06c

File tree

147 files changed

+1546
-3693
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

147 files changed

+1546
-3693
lines changed

accounts/abi/bind/util.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,8 +22,7 @@ import (
2222

2323
"github.com/ethereum/go-ethereum/common"
2424
"github.com/ethereum/go-ethereum/core/types"
25-
"github.com/ethereum/go-ethereum/logger"
26-
"github.com/ethereum/go-ethereum/logger/glog"
25+
"github.com/ethereum/go-ethereum/log"
2726
"golang.org/x/net/context"
2827
)
2928

@@ -39,9 +38,9 @@ func WaitMined(ctx context.Context, b DeployBackend, tx *types.Transaction) (*ty
3938
return receipt, nil
4039
}
4140
if err != nil {
42-
glog.V(logger.Detail).Infof("tx %x error: %v", loghash, err)
41+
log.Trace(fmt.Sprintf("tx %x error: %v", loghash, err))
4342
} else {
44-
glog.V(logger.Detail).Infof("tx %x not yet mined...", loghash)
43+
log.Trace(fmt.Sprintf("tx %x not yet mined...", loghash))
4544
}
4645
// Wait for the next round.
4746
select {

accounts/keystore/account_cache.go

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,8 +30,7 @@ import (
3030

3131
"github.com/ethereum/go-ethereum/accounts"
3232
"github.com/ethereum/go-ethereum/common"
33-
"github.com/ethereum/go-ethereum/logger"
34-
"github.com/ethereum/go-ethereum/logger/glog"
33+
"github.com/ethereum/go-ethereum/log"
3534
)
3635

3736
// Minimum amount of time between cache reloads. This limit applies if the platform does
@@ -210,8 +209,8 @@ func (ac *accountCache) close() {
210209
// Callers must hold ac.mu.
211210
func (ac *accountCache) reload() {
212211
accounts, err := ac.scan()
213-
if err != nil && glog.V(logger.Debug) {
214-
glog.Errorf("can't load keys: %v", err)
212+
if err != nil {
213+
log.Debug(fmt.Sprintf("can't load keys: %v", err))
215214
}
216215
ac.all = accounts
217216
sort.Sort(ac.all)
@@ -225,7 +224,7 @@ func (ac *accountCache) reload() {
225224
case ac.notify <- struct{}{}:
226225
default:
227226
}
228-
glog.V(logger.Debug).Infof("reloaded keys, cache has %d accounts", len(ac.all))
227+
log.Debug(fmt.Sprintf("reloaded keys, cache has %d accounts", len(ac.all)))
229228
}
230229

231230
func (ac *accountCache) scan() ([]accounts.Account, error) {
@@ -244,12 +243,12 @@ func (ac *accountCache) scan() ([]accounts.Account, error) {
244243
for _, fi := range files {
245244
path := filepath.Join(ac.keydir, fi.Name())
246245
if skipKeyFile(fi) {
247-
glog.V(logger.Detail).Infof("ignoring file %s", path)
246+
log.Trace(fmt.Sprintf("ignoring file %s", path))
248247
continue
249248
}
250249
fd, err := os.Open(path)
251250
if err != nil {
252-
glog.V(logger.Detail).Infoln(err)
251+
log.Trace(fmt.Sprint(err))
253252
continue
254253
}
255254
buf.Reset(fd)
@@ -259,9 +258,9 @@ func (ac *accountCache) scan() ([]accounts.Account, error) {
259258
addr := common.HexToAddress(keyJSON.Address)
260259
switch {
261260
case err != nil:
262-
glog.V(logger.Debug).Infof("can't decode key %s: %v", path, err)
261+
log.Debug(fmt.Sprintf("can't decode key %s: %v", path, err))
263262
case (addr == common.Address{}):
264-
glog.V(logger.Debug).Infof("can't decode key %s: missing or zero address", path)
263+
log.Debug(fmt.Sprintf("can't decode key %s: missing or zero address", path))
265264
default:
266265
addrs = append(addrs, accounts.Account{Address: addr, URL: accounts.URL{Scheme: KeyStoreScheme, Path: path}})
267266
}

accounts/keystore/watch.go

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,10 +19,10 @@
1919
package keystore
2020

2121
import (
22+
"fmt"
2223
"time"
2324

24-
"github.com/ethereum/go-ethereum/logger"
25-
"github.com/ethereum/go-ethereum/logger/glog"
25+
"github.com/ethereum/go-ethereum/log"
2626
"github.com/rjeczalik/notify"
2727
)
2828

@@ -67,12 +67,12 @@ func (w *watcher) loop() {
6767

6868
err := notify.Watch(w.ac.keydir, w.ev, notify.All)
6969
if err != nil {
70-
glog.V(logger.Detail).Infof("can't watch %s: %v", w.ac.keydir, err)
70+
log.Trace(fmt.Sprintf("can't watch %s: %v", w.ac.keydir, err))
7171
return
7272
}
7373
defer notify.Stop(w.ev)
74-
glog.V(logger.Detail).Infof("now watching %s", w.ac.keydir)
75-
defer glog.V(logger.Detail).Infof("no longer watching %s", w.ac.keydir)
74+
log.Trace(fmt.Sprintf("now watching %s", w.ac.keydir))
75+
defer log.Trace(fmt.Sprintf("no longer watching %s", w.ac.keydir))
7676

7777
w.ac.mu.Lock()
7878
w.running = true

accounts/usbwallet/ledger_wallet.go

Lines changed: 14 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,7 @@ import (
3434
"github.com/ethereum/go-ethereum/accounts"
3535
"github.com/ethereum/go-ethereum/common"
3636
"github.com/ethereum/go-ethereum/core/types"
37-
"github.com/ethereum/go-ethereum/logger"
38-
"github.com/ethereum/go-ethereum/logger/glog"
37+
"github.com/ethereum/go-ethereum/log"
3938
"github.com/ethereum/go-ethereum/rlp"
4039
"github.com/karalabe/hid"
4140
"golang.org/x/net/context"
@@ -220,8 +219,8 @@ func (w *ledgerWallet) Open(passphrase string) error {
220219
// - libusb on Windows doesn't support hotplug, so we can't detect USB unplugs
221220
// - communication timeout on the Ledger requires a device power cycle to fix
222221
func (w *ledgerWallet) heartbeat() {
223-
glog.V(logger.Debug).Infof("%s health-check started", w.url.String())
224-
defer glog.V(logger.Debug).Infof("%s health-check stopped", w.url.String())
222+
log.Debug(fmt.Sprintf("%s health-check started", w.url.String()))
223+
defer log.Debug(fmt.Sprintf("%s health-check stopped", w.url.String()))
225224

226225
// Execute heartbeat checks until termination or error
227226
var (
@@ -260,7 +259,7 @@ func (w *ledgerWallet) heartbeat() {
260259
}
261260
// In case of error, wait for termination
262261
if err != nil {
263-
glog.V(logger.Debug).Infof("%s health-check failed: %v", w.url.String(), err)
262+
log.Debug(fmt.Sprintf("%s health-check failed: %v", w.url.String(), err))
264263
errc = <-w.healthQuit
265264
}
266265
errc <- err
@@ -348,8 +347,8 @@ func (w *ledgerWallet) Accounts() []accounts.Account {
348347
// selfDerive is an account derivation loop that upon request attempts to find
349348
// new non-zero accounts.
350349
func (w *ledgerWallet) selfDerive() {
351-
glog.V(logger.Debug).Infof("%s self-derivation started", w.url.String())
352-
defer glog.V(logger.Debug).Infof("%s self-derivation stopped", w.url.String())
350+
log.Debug(fmt.Sprintf("%s self-derivation started", w.url.String()))
351+
defer log.Debug(fmt.Sprintf("%s self-derivation stopped", w.url.String()))
353352

354353
// Execute self-derivations until termination or error
355354
var (
@@ -394,7 +393,7 @@ func (w *ledgerWallet) selfDerive() {
394393
// Retrieve the next derived Ethereum account
395394
if nextAddr == (common.Address{}) {
396395
if nextAddr, err = w.ledgerDerive(nextPath); err != nil {
397-
glog.V(logger.Warn).Infof("%s self-derivation failed: %v", w.url.String(), err)
396+
log.Warn(fmt.Sprintf("%s self-derivation failed: %v", w.url.String(), err))
398397
break
399398
}
400399
}
@@ -405,12 +404,12 @@ func (w *ledgerWallet) selfDerive() {
405404
)
406405
balance, err = w.deriveChain.BalanceAt(context, nextAddr, nil)
407406
if err != nil {
408-
glog.V(logger.Warn).Infof("%s self-derivation balance retrieval failed: %v", w.url.String(), err)
407+
log.Warn(fmt.Sprintf("%s self-derivation balance retrieval failed: %v", w.url.String(), err))
409408
break
410409
}
411410
nonce, err = w.deriveChain.NonceAt(context, nextAddr, nil)
412411
if err != nil {
413-
glog.V(logger.Warn).Infof("%s self-derivation nonce retrieval failed: %v", w.url.String(), err)
412+
log.Warn(fmt.Sprintf("%s self-derivation nonce retrieval failed: %v", w.url.String(), err))
414413
break
415414
}
416415
// If the next account is empty, stop self-derivation, but add it nonetheless
@@ -430,7 +429,7 @@ func (w *ledgerWallet) selfDerive() {
430429

431430
// Display a log message to the user for new (or previously empty accounts)
432431
if _, known := w.paths[nextAddr]; !known || (!empty && nextAddr == w.deriveNextAddr) {
433-
glog.V(logger.Info).Infof("%s discovered %s (balance %22v, nonce %4d) at %s", w.url.String(), nextAddr.Hex(), balance, nonce, path)
432+
log.Info(fmt.Sprintf("%s discovered %s (balance %22v, nonce %4d) at %s", w.url.String(), nextAddr.Hex(), balance, nonce, path))
434433
}
435434
// Fetch the next potential account
436435
if !empty {
@@ -469,7 +468,7 @@ func (w *ledgerWallet) selfDerive() {
469468
}
470469
// In case of error, wait for termination
471470
if err != nil {
472-
glog.V(logger.Debug).Infof("%s self-derivation failed: %s", w.url.String(), err)
471+
log.Debug(fmt.Sprintf("%s self-derivation failed: %s", w.url.String(), err))
473472
errc = <-w.deriveQuit
474473
}
475474
errc <- err
@@ -849,9 +848,7 @@ func (w *ledgerWallet) ledgerExchange(opcode ledgerOpcode, p1 ledgerParam1, p2 l
849848
apdu = nil
850849
}
851850
// Send over to the device
852-
if glog.V(logger.Detail) {
853-
glog.Infof("-> %s: %x", w.device.Path, chunk)
854-
}
851+
log.Trace("", "msg", log.Lazy{Fn: func() string { return fmt.Sprintf("-> %s: %x", w.device.Path, chunk) }})
855852
if _, err := w.device.Write(chunk); err != nil {
856853
return nil, err
857854
}
@@ -864,9 +861,8 @@ func (w *ledgerWallet) ledgerExchange(opcode ledgerOpcode, p1 ledgerParam1, p2 l
864861
if _, err := io.ReadFull(w.device, chunk); err != nil {
865862
return nil, err
866863
}
867-
if glog.V(logger.Detail) {
868-
glog.Infof("<- %s: %x", w.device.Path, chunk)
869-
}
864+
log.Trace("", "msg", log.Lazy{Fn: func() string { return fmt.Sprintf("<- %s: %x", w.device.Path, chunk) }})
865+
870866
// Make sure the transport header matches
871867
if chunk[0] != 0x01 || chunk[1] != 0x01 || chunk[2] != 0x05 {
872868
return nil, errReplyInvalidHeader

build/update-license.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ var (
4747
// boring stuff
4848
"vendor/", "tests/files/", "build/",
4949
// don't relicense vendored sources
50-
"crypto/sha3/", "crypto/ecies/", "logger/glog/",
50+
"crypto/sha3/", "crypto/ecies/", "log/",
5151
"crypto/secp256k1/curve.go",
5252
// don't license generated files
5353
"contracts/chequebook/contract/",

cmd/bootnode/main.go

Lines changed: 18 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,8 @@ import (
2323
"fmt"
2424
"os"
2525

26-
"github.com/ethereum/go-ethereum/cmd/utils"
2726
"github.com/ethereum/go-ethereum/crypto"
28-
"github.com/ethereum/go-ethereum/logger/glog"
27+
"github.com/ethereum/go-ethereum/log"
2928
"github.com/ethereum/go-ethereum/p2p/discover"
3029
"github.com/ethereum/go-ethereum/p2p/discv5"
3130
"github.com/ethereum/go-ethereum/p2p/nat"
@@ -42,39 +41,43 @@ func main() {
4241
natdesc = flag.String("nat", "none", "port mapping mechanism (any|none|upnp|pmp|extip:<IP>)")
4342
netrestrict = flag.String("netrestrict", "", "restrict network communication to the given IP networks (CIDR masks)")
4443
runv5 = flag.Bool("v5", false, "run a v5 topic discovery bootnode")
44+
verbosity = flag.Int("verbosity", int(log.LvlInfo), "log verbosity (0-9)")
45+
vmodule = flag.String("vmodule", "", "log verbosity pattern")
4546

4647
nodeKey *ecdsa.PrivateKey
4748
err error
4849
)
49-
flag.Var(glog.GetVerbosity(), "verbosity", "log verbosity (0-9)")
50-
flag.Var(glog.GetVModule(), "vmodule", "log verbosity pattern")
51-
glog.SetToStderr(true)
5250
flag.Parse()
5351

52+
glogger := log.NewGlogHandler(log.StreamHandler(os.Stderr, log.TerminalFormat()))
53+
glogger.Verbosity(log.Lvl(*verbosity))
54+
glogger.Vmodule(*vmodule)
55+
log.Root().SetHandler(glogger)
56+
5457
natm, err := nat.Parse(*natdesc)
5558
if err != nil {
56-
utils.Fatalf("-nat: %v", err)
59+
log.Crit(fmt.Sprintf("-nat: %v", err))
5760
}
5861
switch {
5962
case *genKey != "":
6063
nodeKey, err = crypto.GenerateKey()
6164
if err != nil {
62-
utils.Fatalf("could not generate key: %v", err)
65+
log.Crit(fmt.Sprintf("could not generate key: %v", err))
6366
}
6467
if err = crypto.SaveECDSA(*genKey, nodeKey); err != nil {
65-
utils.Fatalf("%v", err)
68+
log.Crit(fmt.Sprintf("%v", err))
6669
}
6770
case *nodeKeyFile == "" && *nodeKeyHex == "":
68-
utils.Fatalf("Use -nodekey or -nodekeyhex to specify a private key")
71+
log.Crit(fmt.Sprintf("Use -nodekey or -nodekeyhex to specify a private key"))
6972
case *nodeKeyFile != "" && *nodeKeyHex != "":
70-
utils.Fatalf("Options -nodekey and -nodekeyhex are mutually exclusive")
73+
log.Crit(fmt.Sprintf("Options -nodekey and -nodekeyhex are mutually exclusive"))
7174
case *nodeKeyFile != "":
7275
if nodeKey, err = crypto.LoadECDSA(*nodeKeyFile); err != nil {
73-
utils.Fatalf("-nodekey: %v", err)
76+
log.Crit(fmt.Sprintf("-nodekey: %v", err))
7477
}
7578
case *nodeKeyHex != "":
7679
if nodeKey, err = crypto.HexToECDSA(*nodeKeyHex); err != nil {
77-
utils.Fatalf("-nodekeyhex: %v", err)
80+
log.Crit(fmt.Sprintf("-nodekeyhex: %v", err))
7881
}
7982
}
8083

@@ -87,17 +90,17 @@ func main() {
8790
if *netrestrict != "" {
8891
restrictList, err = netutil.ParseNetlist(*netrestrict)
8992
if err != nil {
90-
utils.Fatalf("-netrestrict: %v", err)
93+
log.Crit(fmt.Sprintf("-netrestrict: %v", err))
9194
}
9295
}
9396

9497
if *runv5 {
9598
if _, err := discv5.ListenUDP(nodeKey, *listenAddr, natm, "", restrictList); err != nil {
96-
utils.Fatalf("%v", err)
99+
log.Crit(fmt.Sprintf("%v", err))
97100
}
98101
} else {
99102
if _, err := discover.ListenUDP(nodeKey, *listenAddr, natm, "", restrictList); err != nil {
100-
utils.Fatalf("%v", err)
103+
log.Crit(fmt.Sprintf("%v", err))
101104
}
102105
}
103106

0 commit comments

Comments
 (0)