Merge pull request #133 from vulcanize/vdb-750-add-descriptive-logging
Vdb 750 add descriptive logging
This commit is contained in:
commit
a005e0d04a
@ -143,6 +143,7 @@ func prepConfig() {
|
||||
names := viper.GetStringSlice("exporter.transformerNames")
|
||||
transformers := make(map[string]config.Transformer)
|
||||
for _, name := range names {
|
||||
logWithCommand.Debug("Configuring " + name + " transformer")
|
||||
transformer := viper.GetStringMapString("exporter." + name)
|
||||
p, pOK := transformer["path"]
|
||||
if !pOK || p == "" {
|
||||
|
@ -17,9 +17,8 @@
|
||||
package chunker_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"io/ioutil"
|
||||
"testing"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
@ -17,9 +17,8 @@
|
||||
package event_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"io/ioutil"
|
||||
"testing"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
@ -54,6 +54,7 @@ func (transformer Transformer) Execute(logs []core.HeaderSyncLog) error {
|
||||
logrus.Errorf("error persisting %v record: %v", transformerName, err)
|
||||
return err
|
||||
}
|
||||
logrus.Debug("Persisted log for " + transformerName)
|
||||
|
||||
return nil
|
||||
}
|
||||
|
@ -17,9 +17,8 @@
|
||||
package fetcher_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"io/ioutil"
|
||||
"testing"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
@ -17,9 +17,8 @@
|
||||
package repository_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"io/ioutil"
|
||||
"testing"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
@ -17,9 +17,8 @@
|
||||
package storage_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"io/ioutil"
|
||||
"testing"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
@ -22,8 +22,7 @@ package watcher
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/core"
|
||||
@ -57,7 +56,7 @@ func (watcher *ContractWatcher) AddTransformers(inits interface{}) error {
|
||||
for _, contractTransformer := range watcher.Transformers {
|
||||
err := contractTransformer.Init()
|
||||
if err != nil {
|
||||
log.Print("Unable to initialize transformer:", contractTransformer.GetConfig().Name, err)
|
||||
logrus.Print("Unable to initialize transformer:", contractTransformer.GetConfig().Name, err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
@ -68,7 +67,7 @@ func (watcher *ContractWatcher) Execute() error {
|
||||
for _, contractTransformer := range watcher.Transformers {
|
||||
err := contractTransformer.Execute()
|
||||
if err != nil {
|
||||
log.Error("Unable to execute transformer:", contractTransformer.GetConfig().Name, err)
|
||||
logrus.Error("Unable to execute transformer:", contractTransformer.GetConfig().Name, err)
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
@ -121,7 +121,9 @@ func (storageWatcher StorageWatcher) processRow(diff utils.StorageDiff) {
|
||||
if queueErr != nil {
|
||||
logrus.Warn(fmt.Sprintf("error queueing storage diff: %s", queueErr))
|
||||
}
|
||||
return
|
||||
}
|
||||
logrus.Debugf("Storage diff persisted at block height: %d", diff.BlockHeight)
|
||||
}
|
||||
|
||||
func (storageWatcher StorageWatcher) processQueue() {
|
||||
|
@ -20,10 +20,9 @@ import (
|
||||
"io/ioutil"
|
||||
"testing"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func TestShared(t *testing.T) {
|
||||
@ -32,5 +31,5 @@ func TestShared(t *testing.T) {
|
||||
}
|
||||
|
||||
var _ = BeforeSuite(func() {
|
||||
log.SetOutput(ioutil.Discard)
|
||||
logrus.SetOutput(ioutil.Discard)
|
||||
})
|
||||
|
9
main.go
9
main.go
@ -2,22 +2,21 @@ package main
|
||||
|
||||
import (
|
||||
"github.com/vulcanize/vulcanizedb/cmd"
|
||||
|
||||
"os"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
func main() {
|
||||
log.SetFormatter(&log.JSONFormatter{
|
||||
logrus.SetFormatter(&logrus.JSONFormatter{
|
||||
PrettyPrint: true,
|
||||
})
|
||||
file, err := os.OpenFile("vulcanizedb.log",
|
||||
os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
|
||||
if err == nil {
|
||||
log.SetOutput(file)
|
||||
logrus.SetOutput(file)
|
||||
} else {
|
||||
log.Info("Failed to log to file, using default stderr")
|
||||
logrus.Info("Failed to log to file, using default stderr")
|
||||
}
|
||||
|
||||
cmd.Execute()
|
||||
|
@ -17,9 +17,8 @@
|
||||
package postgres_test
|
||||
|
||||
import (
|
||||
"testing"
|
||||
|
||||
"io/ioutil"
|
||||
"testing"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
|
@ -18,6 +18,7 @@ package eth
|
||||
|
||||
import (
|
||||
"errors"
|
||||
|
||||
"math/big"
|
||||
"strconv"
|
||||
|
||||
@ -25,6 +26,7 @@ import (
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
"github.com/ethereum/go-ethereum/common/hexutil"
|
||||
"github.com/ethereum/go-ethereum/core/types"
|
||||
"github.com/sirupsen/logrus"
|
||||
"golang.org/x/net/context"
|
||||
|
||||
"github.com/vulcanize/vulcanizedb/pkg/core"
|
||||
@ -58,6 +60,7 @@ func NewBlockChain(ethClient core.EthClient, rpcClient core.RPCClient, node core
|
||||
|
||||
func (blockChain *BlockChain) GetBlockByNumber(blockNumber int64) (block core.Block, err error) {
|
||||
gethBlock, err := blockChain.ethClient.BlockByNumber(context.Background(), big.NewInt(blockNumber))
|
||||
logrus.Debugf("GetBlockByNumber called with block %d", blockNumber)
|
||||
if err != nil {
|
||||
return block, err
|
||||
}
|
||||
@ -66,6 +69,7 @@ func (blockChain *BlockChain) GetBlockByNumber(blockNumber int64) (block core.Bl
|
||||
|
||||
func (blockChain *BlockChain) GetEthLogsWithCustomQuery(query ethereum.FilterQuery) ([]types.Log, error) {
|
||||
gethLogs, err := blockChain.ethClient.FilterLogs(context.Background(), query)
|
||||
logrus.Debug("GetEthLogsWithCustomQuery called")
|
||||
if err != nil {
|
||||
return []types.Log{}, err
|
||||
}
|
||||
@ -73,6 +77,7 @@ func (blockChain *BlockChain) GetEthLogsWithCustomQuery(query ethereum.FilterQue
|
||||
}
|
||||
|
||||
func (blockChain *BlockChain) GetHeaderByNumber(blockNumber int64) (header core.Header, err error) {
|
||||
logrus.Debugf("GetHeaderByNumber called with block %d", blockNumber)
|
||||
if blockChain.node.NetworkID == core.KOVAN_NETWORK_ID {
|
||||
return blockChain.getPOAHeader(blockNumber)
|
||||
}
|
||||
@ -80,6 +85,7 @@ func (blockChain *BlockChain) GetHeaderByNumber(blockNumber int64) (header core.
|
||||
}
|
||||
|
||||
func (blockChain *BlockChain) GetHeadersByNumbers(blockNumbers []int64) (header []core.Header, err error) {
|
||||
logrus.Debug("GetHeadersByNumbers called")
|
||||
if blockChain.node.NetworkID == core.KOVAN_NETWORK_ID {
|
||||
return blockChain.getPOAHeaders(blockNumbers)
|
||||
}
|
||||
@ -268,5 +274,6 @@ func (blockChain *BlockChain) getPOWHeaders(blockNumbers []int64) (headers []cor
|
||||
}
|
||||
|
||||
func (blockChain *BlockChain) GetAccountBalance(address common.Address, blockNumber *big.Int) (*big.Int, error) {
|
||||
logrus.Debug("GetAccountBalance called")
|
||||
return blockChain.ethClient.BalanceAt(context.Background(), address, blockNumber)
|
||||
}
|
||||
|
@ -17,8 +17,7 @@
|
||||
package testing
|
||||
|
||||
import (
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/sirupsen/logrus"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/core"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/eth"
|
||||
"github.com/vulcanize/vulcanizedb/test_config"
|
||||
@ -34,7 +33,7 @@ func SampleContract() core.Contract {
|
||||
func sampleAbiFileContents() string {
|
||||
abiFileContents, err := eth.ReadAbiFile(test_config.ABIFilePath + "sample_abi.json")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
logrus.Fatal(err)
|
||||
}
|
||||
return abiFileContents
|
||||
}
|
||||
|
@ -17,12 +17,11 @@
|
||||
package history_test
|
||||
|
||||
import (
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
|
||||
"io/ioutil"
|
||||
"testing"
|
||||
|
||||
. "github.com/onsi/ginkgo"
|
||||
. "github.com/onsi/gomega"
|
||||
log "github.com/sirupsen/logrus"
|
||||
)
|
||||
|
||||
|
@ -17,7 +17,7 @@
|
||||
package history
|
||||
|
||||
import (
|
||||
log "github.com/sirupsen/logrus"
|
||||
"github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/vulcanize/vulcanizedb/pkg/core"
|
||||
"github.com/vulcanize/vulcanizedb/pkg/datastore"
|
||||
@ -27,22 +27,22 @@ import (
|
||||
func PopulateMissingHeaders(blockChain core.BlockChain, headerRepository datastore.HeaderRepository, startingBlockNumber int64) (int, error) {
|
||||
lastBlock, err := blockChain.LastBlock()
|
||||
if err != nil {
|
||||
log.Error("PopulateMissingHeaders: Error getting last block: ", err)
|
||||
logrus.Error("PopulateMissingHeaders: Error getting last block: ", err)
|
||||
return 0, err
|
||||
}
|
||||
|
||||
blockNumbers, err := headerRepository.MissingBlockNumbers(startingBlockNumber, lastBlock.Int64(), blockChain.Node().ID)
|
||||
if err != nil {
|
||||
log.Error("PopulateMissingHeaders: Error getting missing block numbers: ", err)
|
||||
logrus.Error("PopulateMissingHeaders: Error getting missing block numbers: ", err)
|
||||
return 0, err
|
||||
} else if len(blockNumbers) == 0 {
|
||||
return 0, nil
|
||||
}
|
||||
|
||||
log.Debug(getBlockRangeString(blockNumbers))
|
||||
logrus.Debug(getBlockRangeString(blockNumbers))
|
||||
_, err = RetrieveAndUpdateHeaders(blockChain, headerRepository, blockNumbers)
|
||||
if err != nil {
|
||||
log.Error("PopulateMissingHeaders: Error getting/updating headers: ", err)
|
||||
logrus.Error("PopulateMissingHeaders: Error getting/updating headers: ", err)
|
||||
return 0, err
|
||||
}
|
||||
return len(blockNumbers), nil
|
||||
|
@ -20,6 +20,7 @@ import (
|
||||
"fmt"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/vulcanize/vulcanizedb/pkg/core"
|
||||
)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user