Replaced loggers in `node/` with custom shared logger

pull/1175/head
Kai Lee 5 years ago
parent 7aaa06faa3
commit eb1f1b56d1
  1. 5
      node/contract.go
  2. 2
      node/node_newblock.go
  3. 11
      node/rpc.go
  4. 4
      node/worker/worker.go

@ -10,7 +10,6 @@ import (
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/common/math" "github.com/ethereum/go-ethereum/common/math"
"github.com/ethereum/go-ethereum/crypto" "github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/params"
"github.com/harmony-one/harmony/common/denominations" "github.com/harmony-one/harmony/common/denominations"
@ -138,7 +137,7 @@ func (node *Node) getDeployedStakingContract() common.Address {
func (node *Node) GetNonceOfAddress(address common.Address) uint64 { func (node *Node) GetNonceOfAddress(address common.Address) uint64 {
state, err := node.Blockchain().State() state, err := node.Blockchain().State()
if err != nil { if err != nil {
log.Error("Failed to get chain state", "Error", err) utils.GetLogger().Error("Failed to get chain state", "Error", err)
return 0 return 0
} }
return state.GetNonce(address) return state.GetNonce(address)
@ -148,7 +147,7 @@ func (node *Node) GetNonceOfAddress(address common.Address) uint64 {
func (node *Node) GetBalanceOfAddress(address common.Address) (*big.Int, error) { func (node *Node) GetBalanceOfAddress(address common.Address) (*big.Int, error) {
state, err := node.Blockchain().State() state, err := node.Blockchain().State()
if err != nil { if err != nil {
log.Error("Failed to get chain state", "Error", err) utils.GetLogger().Error("Failed to get chain state", "Error", err)
return nil, err return nil, err
} }
return state.GetBalance(address), nil return state.GetBalance(address), nil

@ -83,7 +83,7 @@ func (node *Node) WaitForConsensusReadyv2(readySignal chan struct{}, stopChan ch
err = node.Worker.UpdateCurrent(coinbase) err = node.Worker.UpdateCurrent(coinbase)
if err != nil { if err != nil {
log.Debug("Failed updating worker's state", "Error", err) utils.GetLogger().Debug("Failed updating worker's state", "Error", err)
continue continue
} }
newBlock, err = node.Worker.Commit(sig, mask, viewID, coinbase) newBlock, err = node.Worker.Commit(sig, mask, viewID, coinbase)

@ -7,11 +7,12 @@ import (
"strings" "strings"
"github.com/ethereum/go-ethereum/event" "github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/rpc" "github.com/ethereum/go-ethereum/rpc"
"github.com/harmony-one/harmony/hmy" "github.com/harmony-one/harmony/hmy"
"github.com/harmony-one/harmony/internal/hmyapi" "github.com/harmony-one/harmony/internal/hmyapi"
"github.com/harmony-one/harmony/internal/hmyapi/filters" "github.com/harmony-one/harmony/internal/hmyapi/filters"
"github.com/harmony-one/harmony/internal/utils"
) )
const ( const (
@ -81,7 +82,7 @@ func (node *Node) startHTTP(endpoint string, apis []rpc.API, modules []string, c
return err return err
} }
log.Info("HTTP endpoint opened", "url", fmt.Sprintf("http://%s", endpoint), "cors", strings.Join(cors, ","), "vhosts", strings.Join(vhosts, ",")) utils.GetLogger().Info("HTTP endpoint opened", "url", fmt.Sprintf("http://%s", endpoint), "cors", strings.Join(cors, ","), "vhosts", strings.Join(vhosts, ","))
// All listeners booted successfully // All listeners booted successfully
httpListener = listener httpListener = listener
httpHandler = handler httpHandler = handler
@ -95,7 +96,7 @@ func (node *Node) stopHTTP() {
httpListener.Close() httpListener.Close()
httpListener = nil httpListener = nil
log.Info("HTTP endpoint closed", "url", fmt.Sprintf("http://%s", httpEndpoint)) utils.GetLogger().Info("HTTP endpoint closed", "url", fmt.Sprintf("http://%s", httpEndpoint))
} }
if httpHandler != nil { if httpHandler != nil {
httpHandler.Stop() httpHandler.Stop()
@ -113,7 +114,7 @@ func (node *Node) startWS(endpoint string, apis []rpc.API, modules []string, wsO
if err != nil { if err != nil {
return err return err
} }
log.Info("WebSocket endpoint opened", "url", fmt.Sprintf("ws://%s", listener.Addr())) utils.GetLogger().Info("WebSocket endpoint opened", "url", fmt.Sprintf("ws://%s", listener.Addr()))
// All listeners booted successfully // All listeners booted successfully
wsListener = listener wsListener = listener
wsHandler = handler wsHandler = handler
@ -127,7 +128,7 @@ func (node *Node) stopWS() {
wsListener.Close() wsListener.Close()
wsListener = nil wsListener = nil
log.Info("WebSocket endpoint closed", "url", fmt.Sprintf("ws://%s", wsEndpoint)) utils.GetLogger().Info("WebSocket endpoint closed", "url", fmt.Sprintf("ws://%s", wsEndpoint))
} }
if wsHandler != nil { if wsHandler != nil {
wsHandler.Stop() wsHandler.Stop()

@ -5,7 +5,6 @@ import (
"time" "time"
"github.com/ethereum/go-ethereum/common" "github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/params"
consensus_engine "github.com/harmony-one/harmony/consensus/engine" consensus_engine "github.com/harmony-one/harmony/consensus/engine"
@ -14,6 +13,7 @@ import (
"github.com/harmony-one/harmony/core/types" "github.com/harmony-one/harmony/core/types"
"github.com/harmony-one/harmony/core/vm" "github.com/harmony-one/harmony/core/vm"
"github.com/harmony-one/harmony/internal/ctxerror" "github.com/harmony-one/harmony/internal/ctxerror"
"github.com/harmony-one/harmony/internal/utils"
) )
// environment is the worker's current environment and holds all of the current state information. // environment is the worker's current environment and holds all of the current state information.
@ -61,7 +61,7 @@ func (w *Worker) SelectTransactionsForNewBlock(txs types.Transactions, maxNumTxs
if err != nil { if err != nil {
w.current.state.RevertToSnapshot(snap) w.current.state.RevertToSnapshot(snap)
invalid = append(invalid, tx) invalid = append(invalid, tx)
log.Debug("Invalid transaction", "Error", err) utils.GetLogger().Debug("Invalid transaction", "Error", err)
} else { } else {
selected = append(selected, tx) selected = append(selected, tx)
} }

Loading…
Cancel
Save