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/math"
"github.com/ethereum/go-ethereum/crypto"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/params"
"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 {
state, err := node.Blockchain().State()
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 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) {
state, err := node.Blockchain().State()
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 state.GetBalance(address), nil

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

@ -7,11 +7,12 @@ import (
"strings"
"github.com/ethereum/go-ethereum/event"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/rpc"
"github.com/harmony-one/harmony/hmy"
"github.com/harmony-one/harmony/internal/hmyapi"
"github.com/harmony-one/harmony/internal/hmyapi/filters"
"github.com/harmony-one/harmony/internal/utils"
)
const (
@ -81,7 +82,7 @@ func (node *Node) startHTTP(endpoint string, apis []rpc.API, modules []string, c
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
httpListener = listener
httpHandler = handler
@ -95,7 +96,7 @@ func (node *Node) stopHTTP() {
httpListener.Close()
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 {
httpHandler.Stop()
@ -113,7 +114,7 @@ func (node *Node) startWS(endpoint string, apis []rpc.API, modules []string, wsO
if err != nil {
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
wsListener = listener
wsHandler = handler
@ -127,7 +128,7 @@ func (node *Node) stopWS() {
wsListener.Close()
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 {
wsHandler.Stop()

@ -5,7 +5,6 @@ import (
"time"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/params"
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/vm"
"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.
@ -61,7 +61,7 @@ func (w *Worker) SelectTransactionsForNewBlock(txs types.Transactions, maxNumTxs
if err != nil {
w.current.state.RevertToSnapshot(snap)
invalid = append(invalid, tx)
log.Debug("Invalid transaction", "Error", err)
utils.GetLogger().Debug("Invalid transaction", "Error", err)
} else {
selected = append(selected, tx)
}

Loading…
Cancel
Save