aboutsummaryrefslogtreecommitdiffstats
path: root/rpc/client.go
diff options
context:
space:
mode:
Diffstat (limited to 'rpc/client.go')
-rw-r--r--rpc/client.go39
1 files changed, 19 insertions, 20 deletions
diff --git a/rpc/client.go b/rpc/client.go
index 269eb78c8..78a6fe789 100644
--- a/rpc/client.go
+++ b/rpc/client.go
@@ -30,8 +30,7 @@ import (
"sync/atomic"
"time"
- "github.com/ethereum/go-ethereum/logger"
- "github.com/ethereum/go-ethereum/logger/glog"
+ "github.com/ethereum/go-ethereum/log"
"golang.org/x/net/context"
)
@@ -408,9 +407,9 @@ func (c *Client) newMessage(method string, paramsIn ...interface{}) (*jsonrpcMes
func (c *Client) send(ctx context.Context, op *requestOp, msg interface{}) error {
select {
case c.requestOp <- op:
- if glog.V(logger.Detail) {
- glog.Info("sending ", msg)
- }
+ log.Trace("", "msg", log.Lazy{Fn: func() string {
+ return fmt.Sprint("sending ", msg)
+ }})
err := c.write(ctx, msg)
c.sendDone <- err
return err
@@ -445,7 +444,7 @@ func (c *Client) write(ctx context.Context, msg interface{}) error {
func (c *Client) reconnect(ctx context.Context) error {
newconn, err := c.connectFunc(ctx)
if err != nil {
- glog.V(logger.Detail).Infof("reconnect failed: %v", err)
+ log.Trace(fmt.Sprintf("reconnect failed: %v", err))
return err
}
select {
@@ -496,31 +495,31 @@ func (c *Client) dispatch(conn net.Conn) {
for _, msg := range batch {
switch {
case msg.isNotification():
- if glog.V(logger.Detail) {
- glog.Info("<-readResp: notification ", msg)
- }
+ log.Trace("", "msg", log.Lazy{Fn: func() string {
+ return fmt.Sprint("<-readResp: notification ", msg)
+ }})
c.handleNotification(msg)
case msg.isResponse():
- if glog.V(logger.Detail) {
- glog.Info("<-readResp: response ", msg)
- }
+ log.Trace("", "msg", log.Lazy{Fn: func() string {
+ return fmt.Sprint("<-readResp: response ", msg)
+ }})
c.handleResponse(msg)
default:
- if glog.V(logger.Debug) {
- glog.Error("<-readResp: dropping weird message", msg)
- }
+ log.Debug("", "msg", log.Lazy{Fn: func() string {
+ return fmt.Sprint("<-readResp: dropping weird message", msg)
+ }})
// TODO: maybe close
}
}
case err := <-c.readErr:
- glog.V(logger.Debug).Infof("<-readErr: %v", err)
+ log.Debug(fmt.Sprintf("<-readErr: %v", err))
c.closeRequestOps(err)
conn.Close()
reading = false
case newconn := <-c.reconnected:
- glog.V(logger.Debug).Infof("<-reconnected: (reading=%t) %v", reading, conn.RemoteAddr())
+ log.Debug(fmt.Sprintf("<-reconnected: (reading=%t) %v", reading, conn.RemoteAddr()))
if reading {
// Wait for the previous read loop to exit. This is a rare case.
conn.Close()
@@ -577,7 +576,7 @@ func (c *Client) closeRequestOps(err error) {
func (c *Client) handleNotification(msg *jsonrpcMessage) {
if msg.Method != notificationMethod {
- glog.V(logger.Debug).Info("dropping non-subscription message: ", msg)
+ log.Debug(fmt.Sprint("dropping non-subscription message: ", msg))
return
}
var subResult struct {
@@ -585,7 +584,7 @@ func (c *Client) handleNotification(msg *jsonrpcMessage) {
Result json.RawMessage `json:"result"`
}
if err := json.Unmarshal(msg.Params, &subResult); err != nil {
- glog.V(logger.Debug).Info("dropping invalid subscription message: ", msg)
+ log.Debug(fmt.Sprint("dropping invalid subscription message: ", msg))
return
}
if c.subs[subResult.ID] != nil {
@@ -596,7 +595,7 @@ func (c *Client) handleNotification(msg *jsonrpcMessage) {
func (c *Client) handleResponse(msg *jsonrpcMessage) {
op := c.respWait[string(msg.ID)]
if op == nil {
- glog.V(logger.Debug).Infof("unsolicited response %v", msg)
+ log.Debug(fmt.Sprintf("unsolicited response %v", msg))
return
}
delete(c.respWait, string(msg.ID))