I finally got fed up enough with our lousy logging to do something about it.
So: I replaced all instances of printf() in our code with either LogPrint or LogPrintf.
LogPrintf(“foo\n”); is a straight replacement for printf/OutputDebugStringf(“foo\n”). It writes printf-formatted arguments to debug.log (or console if -printtoconsole). Use it for messages that should always go into debug.log (errors, startup info, etc).
LogPrint(“category”, …); is new– it only logs if you pass a -debug=category flag. Run with multiple -debug= arguments to log more than one category (e.g. bitcoind -debug=net -debug=mempool ). I defined the following categories: net mempool rpc alert db addr addrman coindb rand
If y’all like this, feel free to add more categories, rename/combine these, etc.