Repository navigation
New logging - #78
New logging#78
Conversation
| app = dummy.NewDummyApplication() | ||
| } else { | ||
| app = dummy.NewPersistentDummyApplication(*persistencePtr) | ||
| app.(*dummy.PersistentDummyApplication).SetLogger(log.With(logger, "module", "dummy")) |
There was a problem hiding this comment.
it looks a bit ugly, but don't think that SetLogger should be a part of the Application interface.
There was a problem hiding this comment.
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()) |
There was a problem hiding this comment.
hm... what should we do here? pass a logger as an argument?
There was a problem hiding this comment.
Actually thats not a bad idea. Would avoid the ugly SetLogger with the type assertion too
There was a problem hiding this comment.
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)
There was a problem hiding this comment.
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)")) |
There was a problem hiding this comment.
log.Crit does not interrupt the program. Can we continue working if the "data has been corrupted"? If yes, I will remove the Panic.
There was a problem hiding this comment.
Note that during SaveLastBlock we panic
| if err != nil { | ||
| log.Fatal(err.Error()) | ||
| logger.Error(err.Error()) | ||
| os.Exit(1) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Yeh let's not. At least yet.
|
ab0599f to
d2a4b16
Compare
| cli.BaseService = *cmn.NewBaseService(nil, "socketClient", cli) | ||
|
|
||
| // FIXME we are loosing "Starting socketClient" message here | ||
| // add logger to params? |
There was a problem hiding this comment.
add logger to params or extract Start method?
530c688 to
317e917
Compare
No description provided.