Repository navigation
log: Move validation option logging to LoadChainstate() - #25951
Hidden character warning
Conversation
|
One way to test this is to modify bitcoin-chainstate a bit: diff --git a/src/bitcoin-chainstate.cpp b/src/bitcoin-chainstate.cpp
index 7312ae45d4..4ec71ca3fb 100644
--- a/src/bitcoin-chainstate.cpp
+++ b/src/bitcoin-chainstate.cpp
@@ -53,6 +53,10 @@ int main(int argc, char* argv[])
// SETUP: Misc Globals
SelectParams(CBaseChainParams::MAIN);
const CChainParams& chainparams = Params();
+LogInstance().m_print_to_console=true;
+LogInstance().m_file_path = AbsPathForConfigVal("log_debug");
+LogInstance().m_log_timestamps = false;
+Assert(LogInstance().StartLogging());
kernel::Context kernel_context{};
// We can't use a goto here, but we can use an assert since none of theCommand to test: Output diff: @@ -3,6 +3,9 @@ Using RdSeed as an additional entropy source
Using RdRand as an additional entropy source
Using 16 MiB out of 16 MiB requested for signature cache, able to store 524288 elements
Using 16 MiB out of 16 MiB requested for script execution cache, able to store 524288 elements
+Validating signatures for all blocks.
+Setting nMinimumChainWork=0000000000000000000000000000000000000000000000000000000000000000
+Warning: nMinimumChainWork set below default value of 00000000000000000000000000000000000000002927cdceccbd5209e81e80db
Switching active chainstate to Chainstate [ibd] @ height -1 (null)
Opening LevelDB in /tmp/temp_dd/blocks/index
scheduler thread start |
|
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. ConflictsReviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first. |
|
Concept ACK |
|
ACK fa3358b Tested and it works with bitcoin-chainstate as described in #25951 (comment). Note that this pull also changes the placement of this logging from the top to a bit further down after the asmap, "Loading P2P addresses…" and "Cache configuration" sections into the "init message: Loading block index…" one, which seems ok |
|
I kinda would've expected the opposite here, where statuses are returned and the caller (bitcoin-chainstate) can choose to report them as necessary. I've probably missed discussions about logging though. Is the plan to have an instantiated logger in the future so that the caller can control the output? |
|
|
|
I think log prints are useful whether you are calling a library or running a daemon, so it shouldn't be a goal to strip them out. I lost track of the different branches Carl sent (https://github.com/dongcarl/bitcoin/commits/2022-03-kirby-p2.5, etc) but I think all of them kept a global logger object. The global object could be fully or partially replaced with locals if it is a problem. |
This would allow libbitcoinkernel users to see the options logged as well. Currently they would only be logged for bitcoind. Behavior change suggested in the refactoring pull #25704 (comment)