Skip to content
This repository has been archived by the owner on Aug 31, 2021. It is now read-only.

[VDB-751 VDB-754] Bugfix null pointer panic and improve logging #119

Merged
merged 2 commits into from
Jul 18, 2019

Conversation

m0ar
Copy link
Contributor

@m0ar m0ar commented Jul 16, 2019

This PR fixes a possible null pointer panic that occurs when wrong/no ipcpath is set, and improves our logging a bit.

I took the liberty of turning on including method in log entries, and enabled pretty printing. They look this this now, which IMO is a huge improvement since we can at a glance see the method etc.

{
  "file": "/home/br0d/go/src/github.com/vulcanize/vulcanizedb/cmd/root.go:154",
  "func": "github.com/vulcanize/vulcanizedb/cmd.getBlockChain",
  "level": "fatal",
  "msg": "Could not dial client: dial unix: missing address",
  "time": "2019-07-16T13:54:10+02:00"
}

Also learned that we can actually add more fields when we log, instead of churning it all into the same line! Keep this in mind :)

  log.WithFields(log.Fields{
    "animal": "walrus",
    "size":   10,
  }).Info("A group of walrus emerges from the ocean")

@m0ar m0ar force-pushed the watcher-bugfix-and-better-logging branch from 5f70c6c to 968d0f1 Compare July 16, 2019 12:23
Copy link
Collaborator

@i-norden i-norden left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a typo blocking the tests from passing but besides that I think everything looks good, and I agree that this is a huge improvement in the log output!

@@ -120,6 +124,7 @@ func (watcher *EventWatcher) Execute(recheckHeaders constants.TransformerExecuti

transformErr := watcher.transformLogs(logs, header)
if transformErr != nil {
logrus.Errorf("Could not transform logs: ", transformErr)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this is missing a formatting directive.

@@ -129,6 +129,9 @@ func (blockChain *BlockChain) GetTransactions(transactionHashes []common.Hash) (

func (blockChain *BlockChain) LastBlock() (*big.Int, error) {
block, err := blockChain.ethClient.HeaderByNumber(context.Background(), nil)
if err != nil {
return big.NewInt(0), err
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💯

@i-norden i-norden self-requested a review July 17, 2019 15:40
@m0ar m0ar merged commit 2c092e8 into staging Jul 18, 2019
@m0ar m0ar deleted the watcher-bugfix-and-better-logging branch July 18, 2019 07:21
grizz pushed a commit that referenced this pull request Oct 7, 2019
* VDB-751 VDB-754 Bugfix null pointer panic and improve logging

* Fix typo
grizz pushed a commit that referenced this pull request Dec 22, 2019
* VDB-751 VDB-754 Bugfix null pointer panic and improve logging

* Fix typo
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants