Skip to content
This repository was archived by the owner on Jul 15, 2018. It is now read-only.

New logging - #78

Merged
ebuchman merged 8 commits into
developfrom
feature/new-logging
May 5, 2017
Merged

ebuchman merged 8 commits into
developfrom
feature/new-logging

Conversation

@melekes

@melekes melekes commented May 1, 2017

Copy link
Copy Markdown
Contributor

No description provided.

Comment thread cmd/dummy/main.go Outdated
app = dummy.NewDummyApplication()
} else {
app = dummy.NewPersistentDummyApplication(*persistencePtr)
app.(*dummy.PersistentDummyApplication).SetLogger(log.With(logger, "module", "dummy"))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

it looks a bit ugly, but don't think that SetLogger should be a part of the Application interface.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

we could do:

dummyApp := dummy.New...
dummyApp.SetLogger...
app = dummyApp

But thats not much better.

stateTree.Load(lastBlock.AppHash)

log.Notice("Loaded state", "block", lastBlock.Height, "root", stateTree.Hash())
// log.Notice("Loaded state", "block", lastBlock.Height, "root", stateTree.Hash())

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

hm... what should we do here? pass a logger as an argument?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actually thats not a bad idea. Would avoid the ugly SetLogger with the type assertion too

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Maybe we can make an exception here, yes.

I just don't like passing log in a constructor because log is not a required component (i.e application will work without it)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Fair point. It's not a critical log message to have. I've also considered moving the tree loading outside this contructor, so it would take the tree as an arg. But then we still have the ugly SetLogger issue (which isnt really a big deal ...)

if *err != nil {
// DATA HAS BEEN CORRUPTED OR THE SPEC HAS CHANGED
log.Crit(cmn.Fmt("Data has been corrupted or its spec has changed: %v\n", *err))
cmn.PanicCrisis(errors.Wrap(*err, "cannot load last block (data has been corrupted or its spec has changed)"))

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

log.Crit does not interrupt the program. Can we continue working if the "data has been corrupted"? If yes, I will remove the Panic.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Note that during SaveLastBlock we panic

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Don't think so.

Comment thread cmd/dummy/main.go
if err != nil {
log.Fatal(err.Error())
logger.Error(err.Error())
os.Exit(1)

@melekes melekes May 1, 2017 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

What do you think? Do we need a helper method:

func Fatal(logger Logger, msg string, keyvals ...interface{}) {
  logger.Error(msg, keyvals...)
  os.Exit(1)
}

My opinion is that one line does not worth it.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Yeh let's not. At least yet.

@melekes

melekes commented May 1, 2017

Copy link
Copy Markdown
Contributor Author
  • BaseService now exposing Logger field.
  • Service interface has a SetLogger method

@melekes
melekes force-pushed the feature/new-logging branch from ab0599f to d2a4b16 Compare May 4, 2017 12:53
Comment thread client/socket_client.go
cli.BaseService = *cmn.NewBaseService(nil, "socketClient", cli)

// FIXME we are loosing "Starting socketClient" message here
// add logger to params?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

add logger to params or extract Start method?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

#80

@melekes
melekes force-pushed the feature/new-logging branch from 530c688 to 317e917 Compare May 4, 2017 19:25
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