Removes import alias for logrus

This commit is contained in:
yaoandrew 2019-09-10 20:37:12 -07:00 committed by Ian Norden
parent e26fa12af0
commit 0b9f29c300
15 changed files with 49 additions and 55 deletions

View File

@ -17,9 +17,8 @@
package chunker_test package chunker_test
import ( import (
"testing"
"io/ioutil" "io/ioutil"
"testing"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"

View File

@ -17,9 +17,8 @@
package event_test package event_test
import ( import (
"testing"
"io/ioutil" "io/ioutil"
"testing"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"

View File

@ -54,7 +54,7 @@ func (transformer Transformer) Execute(logs []core.HeaderSyncLog) error {
logrus.Errorf("error persisting %v record: %v", transformerName, err) logrus.Errorf("error persisting %v record: %v", transformerName, err)
return err return err
} }
log.Debug("Persisted log for " + transformerName) logrus.Debug("Persisted log for " + transformerName)
return nil return nil
} }

View File

@ -17,9 +17,8 @@
package fetcher_test package fetcher_test
import ( import (
"testing"
"io/ioutil" "io/ioutil"
"testing"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"

View File

@ -17,9 +17,8 @@
package repository_test package repository_test
import ( import (
"testing"
"io/ioutil" "io/ioutil"
"testing"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"

View File

@ -17,9 +17,8 @@
package storage_test package storage_test
import ( import (
"testing"
"io/ioutil" "io/ioutil"
"testing"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"

View File

@ -22,8 +22,7 @@ package watcher
import ( import (
"fmt" "fmt"
"github.com/sirupsen/logrus"
log "github.com/sirupsen/logrus"
"github.com/vulcanize/vulcanizedb/libraries/shared/transformer" "github.com/vulcanize/vulcanizedb/libraries/shared/transformer"
"github.com/vulcanize/vulcanizedb/pkg/core" "github.com/vulcanize/vulcanizedb/pkg/core"
@ -57,7 +56,7 @@ func (watcher *ContractWatcher) AddTransformers(inits interface{}) error {
for _, contractTransformer := range watcher.Transformers { for _, contractTransformer := range watcher.Transformers {
err := contractTransformer.Init() err := contractTransformer.Init()
if err != nil { 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 return err
} }
} }
@ -68,7 +67,7 @@ func (watcher *ContractWatcher) Execute() error {
for _, contractTransformer := range watcher.Transformers { for _, contractTransformer := range watcher.Transformers {
err := contractTransformer.Execute() err := contractTransformer.Execute()
if err != nil { 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 return err
} }
} }

View File

@ -20,10 +20,9 @@ import (
"io/ioutil" "io/ioutil"
"testing" "testing"
log "github.com/sirupsen/logrus"
. "github.com/onsi/ginkgo" . "github.com/onsi/ginkgo"
. "github.com/onsi/gomega" . "github.com/onsi/gomega"
"github.com/sirupsen/logrus"
) )
func TestShared(t *testing.T) { func TestShared(t *testing.T) {
@ -32,5 +31,5 @@ func TestShared(t *testing.T) {
} }
var _ = BeforeSuite(func() { var _ = BeforeSuite(func() {
log.SetOutput(ioutil.Discard) logrus.SetOutput(ioutil.Discard)
}) })

View File

@ -2,22 +2,21 @@ package main
import ( import (
"github.com/vulcanize/vulcanizedb/cmd" "github.com/vulcanize/vulcanizedb/cmd"
"os" "os"
log "github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
) )
func main() { func main() {
log.SetFormatter(&log.JSONFormatter{ logrus.SetFormatter(&logrus.JSONFormatter{
PrettyPrint: true, PrettyPrint: true,
}) })
file, err := os.OpenFile("vulcanizedb.log", file, err := os.OpenFile("vulcanizedb.log",
os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666) os.O_CREATE|os.O_WRONLY|os.O_APPEND, 0666)
if err == nil { if err == nil {
log.SetOutput(file) logrus.SetOutput(file)
} else { } else {
log.Info("Failed to log to file, using default stderr") logrus.Info("Failed to log to file, using default stderr")
} }
cmd.Execute() cmd.Execute()

View File

@ -17,9 +17,13 @@
package config package config
import ( import (
<<<<<<< HEAD
"strings" "strings"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
=======
"github.com/sirupsen/logrus"
>>>>>>> Removes import alias for logrus
"github.com/spf13/viper" "github.com/spf13/viper"
"github.com/vulcanize/vulcanizedb/pkg/eth" "github.com/vulcanize/vulcanizedb/pkg/eth"
) )
@ -91,16 +95,16 @@ func (contractConfig *ContractConfig) PrepConfig() {
var abi string var abi string
abiInterface, abiOK := transformer["abi"] abiInterface, abiOK := transformer["abi"]
if !abiOK { if !abiOK {
log.Warnf("contract %s not configured with an ABI, will attempt to fetch it from Etherscan\r\n", addr) logrus.Warnf("contract %s not configured with an ABI, will attempt to fetch it from Etherscan\r\n", addr)
} else { } else {
abi, abiOK = abiInterface.(string) abi, abiOK = abiInterface.(string)
if !abiOK { if !abiOK {
log.Fatal(addr, "transformer `abi` not of type []string") logrus.Fatal(addr, "transformer `abi` not of type []string")
} }
} }
if abi != "" { if abi != "" {
if _, abiErr := eth.ParseAbi(abi); abiErr != nil { if _, abiErr := eth.ParseAbi(abi); abiErr != nil {
log.Fatal(addr, "transformer `abi` not valid JSON") logrus.Fatal(addr, "transformer `abi` not valid JSON")
} }
} }
contractConfig.Abis[strings.ToLower(addr)] = abi contractConfig.Abis[strings.ToLower(addr)] = abi
@ -109,17 +113,17 @@ func (contractConfig *ContractConfig) PrepConfig() {
events := make([]string, 0) events := make([]string, 0)
eventsInterface, eventsOK := transformer["events"] eventsInterface, eventsOK := transformer["events"]
if !eventsOK { if !eventsOK {
log.Warnf("contract %s not configured with a list of events to watch, will watch all events\r\n", addr) logrus.Warnf("contract %s not configured with a list of events to watch, will watch all events\r\n", addr)
events = []string{} events = []string{}
} else { } else {
eventsI, eventsOK := eventsInterface.([]interface{}) eventsI, eventsOK := eventsInterface.([]interface{})
if !eventsOK { if !eventsOK {
log.Fatal(addr, "transformer `events` not of type []string\r\n") logrus.Fatal(addr, "transformer `events` not of type []string\r\n")
} }
for _, strI := range eventsI { for _, strI := range eventsI {
str, strOK := strI.(string) str, strOK := strI.(string)
if !strOK { if !strOK {
log.Fatal(addr, "transformer `events` not of type []string\r\n") logrus.Fatal(addr, "transformer `events` not of type []string\r\n")
} }
events = append(events, str) events = append(events, str)
} }
@ -130,17 +134,17 @@ func (contractConfig *ContractConfig) PrepConfig() {
methods := make([]string, 0) methods := make([]string, 0)
methodsInterface, methodsOK := transformer["methods"] methodsInterface, methodsOK := transformer["methods"]
if !methodsOK { if !methodsOK {
log.Warnf("contract %s not configured with a list of methods to poll, will not poll any methods\r\n", addr) logrus.Warnf("contract %s not configured with a list of methods to poll, will not poll any methods\r\n", addr)
methods = []string{} methods = []string{}
} else { } else {
methodsI, methodsOK := methodsInterface.([]interface{}) methodsI, methodsOK := methodsInterface.([]interface{})
if !methodsOK { if !methodsOK {
log.Fatal(addr, "transformer `methods` not of type []string\r\n") logrus.Fatal(addr, "transformer `methods` not of type []string\r\n")
} }
for _, strI := range methodsI { for _, strI := range methodsI {
str, strOK := strI.(string) str, strOK := strI.(string)
if !strOK { if !strOK {
log.Fatal(addr, "transformer `methods` not of type []string\r\n") logrus.Fatal(addr, "transformer `methods` not of type []string\r\n")
} }
methods = append(methods, str) methods = append(methods, str)
} }
@ -151,17 +155,17 @@ func (contractConfig *ContractConfig) PrepConfig() {
eventArgs := make([]string, 0) eventArgs := make([]string, 0)
eventArgsInterface, eventArgsOK := transformer["eventArgs"] eventArgsInterface, eventArgsOK := transformer["eventArgs"]
if !eventArgsOK { if !eventArgsOK {
log.Warnf("contract %s not configured with a list of event arguments to filter for, will not filter events for specific emitted values\r\n", addr) logrus.Warnf("contract %s not configured with a list of event arguments to filter for, will not filter events for specific emitted values\r\n", addr)
eventArgs = []string{} eventArgs = []string{}
} else { } else {
eventArgsI, eventArgsOK := eventArgsInterface.([]interface{}) eventArgsI, eventArgsOK := eventArgsInterface.([]interface{})
if !eventArgsOK { if !eventArgsOK {
log.Fatal(addr, "transformer `eventArgs` not of type []string\r\n") logrus.Fatal(addr, "transformer `eventArgs` not of type []string\r\n")
} }
for _, strI := range eventArgsI { for _, strI := range eventArgsI {
str, strOK := strI.(string) str, strOK := strI.(string)
if !strOK { if !strOK {
log.Fatal(addr, "transformer `eventArgs` not of type []string\r\n") logrus.Fatal(addr, "transformer `eventArgs` not of type []string\r\n")
} }
eventArgs = append(eventArgs, str) eventArgs = append(eventArgs, str)
} }
@ -172,17 +176,17 @@ func (contractConfig *ContractConfig) PrepConfig() {
methodArgs := make([]string, 0) methodArgs := make([]string, 0)
methodArgsInterface, methodArgsOK := transformer["methodArgs"] methodArgsInterface, methodArgsOK := transformer["methodArgs"]
if !methodArgsOK { if !methodArgsOK {
log.Warnf("contract %s not configured with a list of method argument values to poll with, will poll methods with all available arguments\r\n", addr) logrus.Warnf("contract %s not configured with a list of method argument values to poll with, will poll methods with all available arguments\r\n", addr)
methodArgs = []string{} methodArgs = []string{}
} else { } else {
methodArgsI, methodArgsOK := methodArgsInterface.([]interface{}) methodArgsI, methodArgsOK := methodArgsInterface.([]interface{})
if !methodArgsOK { if !methodArgsOK {
log.Fatal(addr, "transformer `methodArgs` not of type []string\r\n") logrus.Fatal(addr, "transformer `methodArgs` not of type []string\r\n")
} }
for _, strI := range methodArgsI { for _, strI := range methodArgsI {
str, strOK := strI.(string) str, strOK := strI.(string)
if !strOK { if !strOK {
log.Fatal(addr, "transformer `methodArgs` not of type []string\r\n") logrus.Fatal(addr, "transformer `methodArgs` not of type []string\r\n")
} }
methodArgs = append(methodArgs, str) methodArgs = append(methodArgs, str)
} }
@ -192,11 +196,11 @@ func (contractConfig *ContractConfig) PrepConfig() {
// Get and check startingBlock // Get and check startingBlock
startInterface, startOK := transformer["startingblock"] startInterface, startOK := transformer["startingblock"]
if !startOK { if !startOK {
log.Fatal(addr, "transformer config is missing `startingBlock` value\r\n") logrus.Fatal(addr, "transformer config is missing `startingBlock` value\r\n")
} }
start, startOK := startInterface.(int64) start, startOK := startInterface.(int64)
if !startOK { if !startOK {
log.Fatal(addr, "transformer `startingBlock` not of type int\r\n") logrus.Fatal(addr, "transformer `startingBlock` not of type int\r\n")
} }
contractConfig.StartingBlocks[strings.ToLower(addr)] = start contractConfig.StartingBlocks[strings.ToLower(addr)] = start
@ -204,13 +208,13 @@ func (contractConfig *ContractConfig) PrepConfig() {
var piping bool var piping bool
_, pipeOK := transformer["piping"] _, pipeOK := transformer["piping"]
if !pipeOK { if !pipeOK {
log.Warnf("contract %s does not have its `piping` set, by default piping is turned off\r\n", addr) logrus.Warnf("contract %s does not have its `piping` set, by default piping is turned off\r\n", addr)
piping = false piping = false
} else { } else {
pipingInterface := transformer["piping"] pipingInterface := transformer["piping"]
piping, pipeOK = pipingInterface.(bool) piping, pipeOK = pipingInterface.(bool)
if !pipeOK { if !pipeOK {
log.Fatal(addr, "transformer `piping` not of type bool\r\n") logrus.Fatal(addr, "transformer `piping` not of type bool\r\n")
} }
} }
contractConfig.Piping[strings.ToLower(addr)] = piping contractConfig.Piping[strings.ToLower(addr)] = piping

View File

@ -17,9 +17,8 @@
package postgres_test package postgres_test
import ( import (
"testing"
"io/ioutil" "io/ioutil"
"testing"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"

View File

@ -17,8 +17,7 @@
package testing package testing
import ( import (
log "github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/vulcanize/vulcanizedb/pkg/core" "github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/pkg/eth" "github.com/vulcanize/vulcanizedb/pkg/eth"
"github.com/vulcanize/vulcanizedb/test_config" "github.com/vulcanize/vulcanizedb/test_config"
@ -34,7 +33,7 @@ func SampleContract() core.Contract {
func sampleAbiFileContents() string { func sampleAbiFileContents() string {
abiFileContents, err := eth.ReadAbiFile(test_config.ABIFilePath + "sample_abi.json") abiFileContents, err := eth.ReadAbiFile(test_config.ABIFilePath + "sample_abi.json")
if err != nil { if err != nil {
log.Fatal(err) logrus.Fatal(err)
} }
return abiFileContents return abiFileContents
} }

View File

@ -17,12 +17,11 @@
package history_test package history_test
import ( import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
"io/ioutil" "io/ioutil"
"testing" "testing"
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
) )

View File

@ -17,7 +17,7 @@
package history package history
import ( import (
log "github.com/sirupsen/logrus" "github.com/sirupsen/logrus"
"github.com/vulcanize/vulcanizedb/pkg/core" "github.com/vulcanize/vulcanizedb/pkg/core"
"github.com/vulcanize/vulcanizedb/pkg/datastore" "github.com/vulcanize/vulcanizedb/pkg/datastore"
@ -27,22 +27,22 @@ import (
func PopulateMissingHeaders(blockChain core.BlockChain, headerRepository datastore.HeaderRepository, startingBlockNumber int64) (int, error) { func PopulateMissingHeaders(blockChain core.BlockChain, headerRepository datastore.HeaderRepository, startingBlockNumber int64) (int, error) {
lastBlock, err := blockChain.LastBlock() lastBlock, err := blockChain.LastBlock()
if err != nil { if err != nil {
log.Error("PopulateMissingHeaders: Error getting last block: ", err) logrus.Error("PopulateMissingHeaders: Error getting last block: ", err)
return 0, err return 0, err
} }
blockNumbers, err := headerRepository.MissingBlockNumbers(startingBlockNumber, lastBlock.Int64(), blockChain.Node().ID) blockNumbers, err := headerRepository.MissingBlockNumbers(startingBlockNumber, lastBlock.Int64(), blockChain.Node().ID)
if err != nil { if err != nil {
log.Error("PopulateMissingHeaders: Error getting missing block numbers: ", err) logrus.Error("PopulateMissingHeaders: Error getting missing block numbers: ", err)
return 0, err return 0, err
} else if len(blockNumbers) == 0 { } else if len(blockNumbers) == 0 {
return 0, nil return 0, nil
} }
log.Debug(getBlockRangeString(blockNumbers)) logrus.Debug(getBlockRangeString(blockNumbers))
_, err = RetrieveAndUpdateHeaders(blockChain, headerRepository, blockNumbers) _, err = RetrieveAndUpdateHeaders(blockChain, headerRepository, blockNumbers)
if err != nil { if err != nil {
log.Error("PopulateMissingHeaders: Error getting/updating headers: ", err) logrus.Error("PopulateMissingHeaders: Error getting/updating headers: ", err)
return 0, err return 0, err
} }
return len(blockNumbers), nil return len(blockNumbers), nil

View File

@ -20,6 +20,7 @@ import (
"fmt" "fmt"
log "github.com/sirupsen/logrus" log "github.com/sirupsen/logrus"
"github.com/vulcanize/vulcanizedb/pkg/core" "github.com/vulcanize/vulcanizedb/pkg/core"
) )