replace log by singleton logging

pull/359/head
Minh Doan 6 years ago committed by Minh Doan
parent 71e58a4c8a
commit 7a37836b35
  1. 17
      api/services/syncing/downloader/client.go
  2. 1
      p2p/host/message.go

@ -4,12 +4,11 @@ import (
"context"
"encoding/binary"
"fmt"
"log"
"time"
"google.golang.org/grpc"
pb "github.com/harmony-one/harmony/api/services/syncing/downloader/proto"
"github.com/harmony-one/harmony/internal/utils"
"google.golang.org/grpc"
)
// Client is the client model for downloader package.
@ -26,7 +25,7 @@ func ClientSetup(ip, port string) *Client {
var err error
client.conn, err = grpc.Dial(fmt.Sprintf("%s:%s", ip, port), client.opts...)
if err != nil {
log.Printf("client.go:ClientSetup fail to dial: %v", err)
utils.GetLogInstance().Info("client.go:ClientSetup fail to dial: ", "error", err)
return nil
}
@ -38,7 +37,7 @@ func ClientSetup(ip, port string) *Client {
func (client *Client) Close() {
err := client.conn.Close()
if err != nil {
log.Printf("unable to close connection %v with error %v ", client.conn, err)
utils.GetLogInstance().Info("unable to close connection ")
}
}
@ -49,7 +48,7 @@ func (client *Client) GetBlockHashes(startHash []byte) *pb.DownloaderResponse {
request := &pb.DownloaderRequest{Type: pb.DownloaderRequest_HEADER, BlockHash: startHash}
response, err := client.dlClient.Query(ctx, request)
if err != nil {
log.Printf("[SYNC] GetBlockHashes query failed with error %v", err)
utils.GetLogInstance().Info("[SYNC] GetBlockHashes query failed", "error", err)
}
return response
}
@ -66,7 +65,7 @@ func (client *Client) GetBlocks(hashes [][]byte) *pb.DownloaderResponse {
}
response, err := client.dlClient.Query(ctx, request)
if err != nil {
log.Printf("[SYNC] downloader/client.go:GetBlocks query failed with error %v", err)
utils.GetLogInstance().Info("[SYNC] downloader/client.go:GetBlocks query failed.", "error", err)
}
return response
}
@ -81,7 +80,7 @@ func (client *Client) Register(hash []byte) *pb.DownloaderResponse {
copy(request.PeerHash, hash)
response, err := client.dlClient.Query(ctx, request)
if err != nil {
log.Printf("[SYNC] client.go:Register failed with code %v", err)
utils.GetLogInstance().Info("[SYNC] client.go:Register failed.", "error", err)
}
return response
}
@ -105,7 +104,7 @@ func (client *Client) PushNewBlock(peerID uint32, blockHash []byte, timeout bool
response, err := client.dlClient.Query(ctx, request)
if err != nil {
log.Printf("[SYNC] unable to send new block to unsync node with error: %v", err)
utils.GetLogInstance().Info("[SYNC] unable to send new block to unsync node", "error", err)
}
return response
}

@ -106,7 +106,6 @@ func send(h p2p.Host, peer p2p.Peer, message []byte, lostPeer chan p2p.Peer) {
// DialWithSocketClient joins host port and establishes connection
func DialWithSocketClient(ip, port string) (conn net.Conn, err error) {
//log.Printf("Sending message to ip %s and port %s\n", ip, port)
addr := net.JoinHostPort(ip, port)
conn, err = net.Dial("tcp", addr)
return

Loading…
Cancel
Save