Adds ability to set log level from toml or CLI args

This commit is contained in:
Andrew J Yao
2019-06-27 11:14:11 -07:00
parent f0a7a7d999
commit 11a65c525c
8 changed files with 38 additions and 16 deletions
+6 -1
View File
@@ -17,6 +17,7 @@
package history
import (
"fmt"
log "github.com/sirupsen/logrus"
"github.com/vulcanize/vulcanizedb/pkg/core"
@@ -35,7 +36,7 @@ func PopulateMissingBlocks(blockchain core.BlockChain, blockRepository datastore
return 0, nil
}
log.Printf("Backfilling %d blocks\n\n", len(blockRange))
log.Debug(getBlockRangeString(blockRange))
_, err = RetrieveAndUpdateBlocks(blockchain, blockRepository, blockRange)
if err != nil {
log.Error("PopulateMissingBlocks: error gettings/updating blocks: ", err)
@@ -61,3 +62,7 @@ func RetrieveAndUpdateBlocks(blockchain core.BlockChain, blockRepository datasto
}
return len(blockNumbers), nil
}
func getBlockRangeString(blockRange []int64) string {
return fmt.Sprintf("Backfilling |%v| blocks", len(blockRange))
}
+2 -1
View File
@@ -39,7 +39,7 @@ func PopulateMissingHeaders(blockChain core.BlockChain, headerRepository datasto
return 0, nil
}
log.Printf("Backfilling %d blocks\n\n", len(blockNumbers))
log.Debug(getBlockRangeString(blockNumbers))
_, err = RetrieveAndUpdateHeaders(blockChain, headerRepository, blockNumbers)
if err != nil {
log.Error("PopulateMissingHeaders: Error getting/updating headers:", err)
@@ -61,3 +61,4 @@ func RetrieveAndUpdateHeaders(blockChain core.BlockChain, headerRepository datas
}
return len(blockNumbers), nil
}
+1 -1
View File
@@ -50,6 +50,6 @@ func MakeRange(min, max int64) []int64 {
}
func (window ValidationWindow) GetString() string {
return fmt.Sprintf("Validating Blocks |%v|-- Validation Window --|%v}|",
return fmt.Sprintf("Validating Blocks |%v|-- Validation Window --|%v|",
window.LowerBound, window.UpperBound)
}