PR’ing this early as an RFC because it’s a lot of work that will require constant rebasing. This is the first logical step and is mostly mechanical.
This PR adds an “instance” param to each log function and callsite. As is, there should be no functional change here.
The intention is to allow for a specific instance to be passed in each time we use the logger, rather than the implicit global as we have it now. Eventually (one subsystem/chunk at a time), this will allow us to instantiate a per-context logger, which is necessary for the kernel.
This is my second iteration. The first approach can be seen here: https://github.com/theuni/bitcoin/commit/533e75e81a18a06708bc3dfcee554d344cf1c81b. It was much cleaner and used c++20’s std::source_location
, however it proved to be impossible to do lazy variadic parameter evaluation that way. The approach here is rather dumb, but it should incur no performance penalty.
If there’s a rough consensus on this approach, I’d like to go ahead and get this PR cleaned up and merged so that I can begin the work of converting global LogInstance()
s to real instances. The first major goal would be to allow the kernel/bitcoin-chainstate to be used without the static global instance.
Note that the first commit will not compile. The second is a massive scripted-diff. If that’s a problem, I can add a commit which introduces dummy macros, then switch them back after the scripted-diff.