[Chronik] Add log! and log_chronik! macros
Summary:
- Add CHRONIK log category to BCLog
- Split log_println into log_print (logs unconditionally) and log_print_chronik (logs to category BCLog::CHRONIK)
- Add chronik-util crate
- Add log! (calls log_print) and log_chronik! macro (calls log_print_chronik)
Note: There is no (built-in) equivalent to the __FUNC__ macro in Rust, so we just put <chronik unknown> there. Capturing the current function name is possible but requires a bit of a hack (see https://stackoverflow.com/a/40234666).
Note: __FILE__ in C++ is relative to cwd (e.g. build), but file!() in Rust is relative to /. We haven't spent any time harmonizing this, as this is sufficient for debugging purposes.
Test Plan:
- ninja
- ./src/bitcoind -help: Under -debug option, it lists chronik
- ./src/bitcoind -regtest: Still logs (only) "Starting Chronik..." as before
- ./src/bitcoind -regtest -debug=chronik: Now also logs "Note: Chronik is not implemented yet. These logs are just for testing."
- ./src/bitcoind -regtest -debug=chronik -logsourcelocations: Logs:
[chronik/chronik-lib/src/bridge.rs:11] [<chronik unknown>] Starting Chronik... [chronik/chronik-lib/src/bridge.rs:12] [<chronik unknown>] Note: Chronik is not implemented yet. These logs are just for testing.
Reviewers: Fabien, #bitcoin_abc
Reviewed By: Fabien, #bitcoin_abc
Differential Revision: https://reviews.bitcoinabc.org/D12026