aboutsummaryrefslogtreecommitdiffstats
path: root/node
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 /node
parent47af53f9aaf9aa7b12cd976eb150ccf3d64da6fd (diff)
downloadgo-tangerine-d4fd06c3dc6cd6d2dbd2bfebfee5bcb46a504851.tar
go-tangerine-d4fd06c3dc6cd6d2dbd2bfebfee5bcb46a504851.tar.gz
go-tangerine-d4fd06c3dc6cd6d2dbd2bfebfee5bcb46a504851.tar.bz2
go-tangerine-d4fd06c3dc6cd6d2dbd2bfebfee5bcb46a504851.tar.lz
go-tangerine-d4fd06c3dc6cd6d2dbd2bfebfee5bcb46a504851.tar.xz
go-tangerine-d4fd06c3dc6cd6d2dbd2bfebfee5bcb46a504851.tar.zst
go-tangerine-d4fd06c3dc6cd6d2dbd2bfebfee5bcb46a504851.zip
all: blidly swap out glog to our log15, logs need rework
Diffstat (limited to 'node')
-rw-r--r--node/config.go17
-rw-r--r--node/node.go28
2 files changed, 22 insertions, 23 deletions
diff --git a/node/config.go b/node/config.go
index c09f51747..608c9a6b4 100644
--- a/node/config.go
+++ b/node/config.go
@@ -31,8 +31,7 @@ import (
"github.com/ethereum/go-ethereum/accounts/usbwallet"
"github.com/ethereum/go-ethereum/common"
"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/discover"
"github.com/ethereum/go-ethereum/p2p/discv5"
"github.com/ethereum/go-ethereum/p2p/nat"
@@ -334,7 +333,7 @@ func (c *Config) NodeKey() *ecdsa.PrivateKey {
if c.DataDir == "" {
key, err := crypto.GenerateKey()
if err != nil {
- glog.Fatalf("Failed to generate ephemeral node key: %v", err)
+ log.Crit(fmt.Sprintf("Failed to generate ephemeral node key: %v", err))
}
return key
}
@@ -346,16 +345,16 @@ func (c *Config) NodeKey() *ecdsa.PrivateKey {
// No persistent key found, generate and store a new one.
key, err := crypto.GenerateKey()
if err != nil {
- glog.Fatalf("Failed to generate node key: %v", err)
+ log.Crit(fmt.Sprintf("Failed to generate node key: %v", err))
}
instanceDir := filepath.Join(c.DataDir, c.name())
if err := os.MkdirAll(instanceDir, 0700); err != nil {
- glog.V(logger.Error).Infof("Failed to persist node key: %v", err)
+ log.Error(fmt.Sprintf("Failed to persist node key: %v", err))
return key
}
keyfile = filepath.Join(instanceDir, datadirPrivateKey)
if err := crypto.SaveECDSA(keyfile, key); err != nil {
- glog.V(logger.Error).Infof("Failed to persist node key: %v", err)
+ log.Error(fmt.Sprintf("Failed to persist node key: %v", err))
}
return key
}
@@ -383,7 +382,7 @@ func (c *Config) parsePersistentNodes(path string) []*discover.Node {
// Load the nodes from the config file.
var nodelist []string
if err := common.LoadJSON(path, &nodelist); err != nil {
- glog.V(logger.Error).Infof("Can't load node file %s: %v", path, err)
+ log.Error(fmt.Sprintf("Can't load node file %s: %v", path, err))
return nil
}
// Interpret the list as a discovery node array
@@ -394,7 +393,7 @@ func (c *Config) parsePersistentNodes(path string) []*discover.Node {
}
node, err := discover.ParseNode(url)
if err != nil {
- glog.V(logger.Error).Infof("Node URL %s: %v\n", url, err)
+ log.Error(fmt.Sprintf("Node URL %s: %v\n", url, err))
continue
}
nodes = append(nodes, node)
@@ -442,7 +441,7 @@ func makeAccountManager(conf *Config) (*accounts.Manager, string, error) {
keystore.NewKeyStore(keydir, scryptN, scryptP),
}
if ledgerhub, err := usbwallet.NewLedgerHub(); err != nil {
- glog.V(logger.Warn).Infof("Failed to start Ledger hub, disabling: %v", err)
+ log.Warn(fmt.Sprintf("Failed to start Ledger hub, disabling: %v", err))
} else {
backends = append(backends, ledgerhub)
}
diff --git a/node/node.go b/node/node.go
index 4b56fba4c..c7e28af37 100644
--- a/node/node.go
+++ b/node/node.go
@@ -18,6 +18,7 @@ package node
import (
"errors"
+ "fmt"
"net"
"os"
"path/filepath"
@@ -30,8 +31,7 @@ import (
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/event"
"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/p2p"
"github.com/ethereum/go-ethereum/rpc"
"github.com/syndtr/goleveldb/leveldb/storage"
@@ -173,7 +173,7 @@ func (n *Node) Start() error {
MaxPendingPeers: n.config.MaxPendingPeers,
}
running := &p2p.Server{Config: n.serverConfig}
- glog.V(logger.Info).Infoln("instance:", n.serverConfig.Name)
+ log.Info(fmt.Sprint("instance:", n.serverConfig.Name))
// Otherwise copy and specialize the P2P configuration
services := make(map[reflect.Type]Service)
@@ -301,7 +301,7 @@ func (n *Node) startInProc(apis []rpc.API) error {
if err := handler.RegisterName(api.Namespace, api.Service); err != nil {
return err
}
- glog.V(logger.Debug).Infof("InProc registered %T under '%s'", api.Service, api.Namespace)
+ log.Debug(fmt.Sprintf("InProc registered %T under '%s'", api.Service, api.Namespace))
}
n.inprocHandler = handler
return nil
@@ -327,7 +327,7 @@ func (n *Node) startIPC(apis []rpc.API) error {
if err := handler.RegisterName(api.Namespace, api.Service); err != nil {
return err
}
- glog.V(logger.Debug).Infof("IPC registered %T under '%s'", api.Service, api.Namespace)
+ log.Debug(fmt.Sprintf("IPC registered %T under '%s'", api.Service, api.Namespace))
}
// All APIs registered, start the IPC listener
var (
@@ -338,7 +338,7 @@ func (n *Node) startIPC(apis []rpc.API) error {
return err
}
go func() {
- glog.V(logger.Info).Infof("IPC endpoint opened: %s", n.ipcEndpoint)
+ log.Info(fmt.Sprintf("IPC endpoint opened: %s", n.ipcEndpoint))
for {
conn, err := listener.Accept()
@@ -351,7 +351,7 @@ func (n *Node) startIPC(apis []rpc.API) error {
return
}
// Not closed, just some error; report and continue
- glog.V(logger.Error).Infof("IPC accept failed: %v", err)
+ log.Error(fmt.Sprintf("IPC accept failed: %v", err))
continue
}
go handler.ServeCodec(rpc.NewJSONCodec(conn), rpc.OptionMethodInvocation|rpc.OptionSubscriptions)
@@ -370,7 +370,7 @@ func (n *Node) stopIPC() {
n.ipcListener.Close()
n.ipcListener = nil
- glog.V(logger.Info).Infof("IPC endpoint closed: %s", n.ipcEndpoint)
+ log.Info(fmt.Sprintf("IPC endpoint closed: %s", n.ipcEndpoint))
}
if n.ipcHandler != nil {
n.ipcHandler.Stop()
@@ -396,7 +396,7 @@ func (n *Node) startHTTP(endpoint string, apis []rpc.API, modules []string, cors
if err := handler.RegisterName(api.Namespace, api.Service); err != nil {
return err
}
- glog.V(logger.Debug).Infof("HTTP registered %T under '%s'", api.Service, api.Namespace)
+ log.Debug(fmt.Sprintf("HTTP registered %T under '%s'", api.Service, api.Namespace))
}
}
// All APIs registered, start the HTTP listener
@@ -408,7 +408,7 @@ func (n *Node) startHTTP(endpoint string, apis []rpc.API, modules []string, cors
return err
}
go rpc.NewHTTPServer(cors, handler).Serve(listener)
- glog.V(logger.Info).Infof("HTTP endpoint opened: http://%s", endpoint)
+ log.Info(fmt.Sprintf("HTTP endpoint opened: http://%s", endpoint))
// All listeners booted successfully
n.httpEndpoint = endpoint
@@ -424,7 +424,7 @@ func (n *Node) stopHTTP() {
n.httpListener.Close()
n.httpListener = nil
- glog.V(logger.Info).Infof("HTTP endpoint closed: http://%s", n.httpEndpoint)
+ log.Info(fmt.Sprintf("HTTP endpoint closed: http://%s", n.httpEndpoint))
}
if n.httpHandler != nil {
n.httpHandler.Stop()
@@ -450,7 +450,7 @@ func (n *Node) startWS(endpoint string, apis []rpc.API, modules []string, wsOrig
if err := handler.RegisterName(api.Namespace, api.Service); err != nil {
return err
}
- glog.V(logger.Debug).Infof("WebSocket registered %T under '%s'", api.Service, api.Namespace)
+ log.Debug(fmt.Sprintf("WebSocket registered %T under '%s'", api.Service, api.Namespace))
}
}
// All APIs registered, start the HTTP listener
@@ -462,7 +462,7 @@ func (n *Node) startWS(endpoint string, apis []rpc.API, modules []string, wsOrig
return err
}
go rpc.NewWSServer(wsOrigins, handler).Serve(listener)
- glog.V(logger.Info).Infof("WebSocket endpoint opened: ws://%s", endpoint)
+ log.Info(fmt.Sprintf("WebSocket endpoint opened: ws://%s", endpoint))
// All listeners booted successfully
n.wsEndpoint = endpoint
@@ -478,7 +478,7 @@ func (n *Node) stopWS() {
n.wsListener.Close()
n.wsListener = nil
- glog.V(logger.Info).Infof("WebSocket endpoint closed: ws://%s", n.wsEndpoint)
+ log.Info(fmt.Sprintf("WebSocket endpoint closed: ws://%s", n.wsEndpoint))
}
if n.wsHandler != nil {
n.wsHandler.Stop()