Skip to content

experimental logging

Luke Champine requested to merge log into master

Exploring how we might do logging. The gateway now has fairly comprehensive logs. Eventually we may want to write a custom logger, but using the default one is okay for now. Some thoughts I had:

  • Does it make sense to establish logging conventions (in the same style as our mutex conventions, that is)? e.g. "functions that return an error should not also log that error" or similar.
  • If each module is writing to a separate log file, what's the best way to merge them so that we can see everything in chronological order? Or should all logs be written to the same file, and simply tagged by module? Should we write a "log viewer" tool to assist debugging?
  • How can logs preserve context? That is, if there are two concurrent calls to the same function, their logs are going to be intertwined, so how do you tell how they're grouped?
  • What's the best way to integrate logging with our if DEBUG { panic() } pattern? Maybe the logger could handle it implicitly, like:
func (l *logger) Fatal(v ...interface{}) {
    msg := fmt.Sprint(v...)
    l.output(msg)
    if DEBUG {
        panic(msg)
    }
}

I also noticed that the tester package is apparently a module?? Is there some plan to expand its functionality? Because right now it's just the TempDir function. If it isn't clear how tester will be used, we could just move TempDir to the build package. Speaking of which, SiaTestingDir is now organized by package, rather than throwing all the test folders into one directory. And all the tests use a random RPC port instead of incrementing a number. (This could be done with the API port too, but it'd be kind of a hassle.)

Merge request reports