Remove injection of SubCommand for logs
This commit is contained in:
+14
-13
@@ -63,7 +63,8 @@ must have been composed by the same version of vulcanizedb or else it will not b
|
||||
Specify config location when executing the command:
|
||||
./vulcanizedb execute --config=./environments/config_name.toml`,
|
||||
Run: func(cmd *cobra.Command, args []string) {
|
||||
subCommand = cmd.CalledAs()
|
||||
SubCommand = cmd.CalledAs()
|
||||
LogWithCommand = *log.WithField("SubCommand", SubCommand)
|
||||
execute()
|
||||
},
|
||||
}
|
||||
@@ -75,36 +76,36 @@ func execute() {
|
||||
// Get the plugin path and load the plugin
|
||||
_, pluginPath, err := genConfig.GetPluginPaths()
|
||||
if err != nil {
|
||||
log.WithField("subCommand", subCommand).Fatal(err)
|
||||
LogWithCommand.Fatal(err)
|
||||
}
|
||||
|
||||
fmt.Printf("Executing plugin %s", pluginPath)
|
||||
log.WithField("subCommand", subCommand).Info("linking plugin", pluginPath)
|
||||
LogWithCommand.Info("linking plugin ", pluginPath)
|
||||
plug, err := plugin.Open(pluginPath)
|
||||
if err != nil {
|
||||
log.WithField("subCommand", subCommand).Warn("linking plugin failed")
|
||||
log.WithField("subCommand", subCommand).Fatal(err)
|
||||
LogWithCommand.Warn("linking plugin failed")
|
||||
LogWithCommand.Fatal(err)
|
||||
}
|
||||
|
||||
// Load the `Exporter` symbol from the plugin
|
||||
log.WithField("subCommand", subCommand).Info("loading transformers from plugin")
|
||||
LogWithCommand.Info("loading transformers from plugin")
|
||||
symExporter, err := plug.Lookup("Exporter")
|
||||
if err != nil {
|
||||
log.WithField("subCommand", subCommand).Warn("loading Exporter symbol failed")
|
||||
log.WithField("subCommand", subCommand).Fatal(err)
|
||||
LogWithCommand.Warn("loading Exporter symbol failed")
|
||||
LogWithCommand.Fatal(err)
|
||||
}
|
||||
|
||||
// Assert that the symbol is of type Exporter
|
||||
exporter, ok := symExporter.(Exporter)
|
||||
if !ok {
|
||||
log.WithField("subCommand", subCommand).Fatal("plugged-in symbol not of type Exporter")
|
||||
LogWithCommand.Fatal("plugged-in symbol not of type Exporter")
|
||||
}
|
||||
|
||||
// Use the Exporters export method to load the EventTransformerInitializer, StorageTransformerInitializer, and ContractTransformerInitializer sets
|
||||
ethEventInitializers, ethStorageInitializers, ethContractInitializers := exporter.Export()
|
||||
|
||||
// Setup bc and db objects
|
||||
blockChain := getBlockChain(subCommand)
|
||||
blockChain := getBlockChain()
|
||||
db := utils.LoadPostgres(databaseConfig, blockChain.Node())
|
||||
|
||||
// Execute over transformer sets returned by the exporter
|
||||
@@ -148,7 +149,7 @@ type Exporter interface {
|
||||
func watchEthEvents(w *watcher.EventWatcher, wg *syn.WaitGroup) {
|
||||
defer wg.Done()
|
||||
// Execute over the EventTransformerInitializer set using the watcher
|
||||
log.WithField("subCommand", subCommand).Info("executing event transformers")
|
||||
LogWithCommand.Info("executing event transformers")
|
||||
var recheck constants.TransformerExecution
|
||||
if recheckHeadersArg {
|
||||
recheck = constants.HeaderRecheck
|
||||
@@ -165,7 +166,7 @@ func watchEthEvents(w *watcher.EventWatcher, wg *syn.WaitGroup) {
|
||||
func watchEthStorage(w *watcher.StorageWatcher, wg *syn.WaitGroup) {
|
||||
defer wg.Done()
|
||||
// Execute over the StorageTransformerInitializer set using the storage watcher
|
||||
log.WithField("subCommand", subCommand).Info("executing storage transformers")
|
||||
LogWithCommand.Info("executing storage transformers")
|
||||
ticker := time.NewTicker(pollingInterval)
|
||||
defer ticker.Stop()
|
||||
for range ticker.C {
|
||||
@@ -178,7 +179,7 @@ func watchEthStorage(w *watcher.StorageWatcher, wg *syn.WaitGroup) {
|
||||
func watchEthContract(w *watcher.ContractWatcher, wg *syn.WaitGroup) {
|
||||
defer wg.Done()
|
||||
// Execute over the ContractTransformerInitializer set using the contract watcher
|
||||
log.WithField("subCommand", subCommand).Info("executing contract_watcher transformers")
|
||||
LogWithCommand.Info("executing contract_watcher transformers")
|
||||
ticker := time.NewTicker(pollingInterval)
|
||||
defer ticker.Stop()
|
||||
for range ticker.C {
|
||||
|
||||
Reference in New Issue
Block a user