log: [refactor] Use info level for init logs #32967

pull maflcko wants to merge 2 commits into bitcoin:master from maflcko:2507-log-info-init changing 28 files +120 βˆ’115
  1. maflcko commented at 9:16 am on July 14, 2025: member

    Many of the normal, and expected init logs, which are run once after startup use the deprecated alias of LogInfo.

    Fix that by using LogInfo directly, which is a refactor, except for a few log lines that also have __func__ removed.

    (Also remove the unused trailing \n char while touching those logs)

  2. DrahtBot added the label Utils/log/libs on Jul 14, 2025
  3. DrahtBot commented at 9:16 am on July 14, 2025: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/32967.

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK stickies-v, fanquake
    Stale ACK l0rinc

    If your review is incorrectly listed, please react with πŸ‘Ž to this comment and the bot will ignore it on the next update.

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #33026 (test, refactor: Embedded ASmap selected preparatory work by fjahr)
    • #32748 (fees: prevent redundant estimates flushes by ismaelsadeeq)
    • #31644 (leveldb: show non-default options during init by l0rinc)
    • #30214 (refactor: Improve assumeutxo state representation by ryanofsky)
    • #29641 (scripted-diff: Use LogInfo over LogPrintf [WIP, NOMERGE, DRAFT] by maflcko)
    • #29640 (Fix tiebreak when loading blocks from disk (and add tests for comparing chain ties) by sr-gi)
    • #28792 (Embed default ASMap as binary dump header file by fjahr)

    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.

    LLM Linter (✨ experimental)

    Possible typos and grammar issues:

    • LogInfo(“Setting NODE_NETWORK on non-prune mode”) -> LogInfo(“Setting NODE_NETWORK in non-prune mode”) [β€œin non-prune mode” is the correct preposition]

    drahtbot_id_4_m

  4. maflcko force-pushed on Jul 14, 2025
  5. in src/node/chainstate.cpp:154 in fa595eb5b0 outdated
    152+        LogInfo("Validating signatures for all blocks.");
    153     }
    154-    LogPrintf("Setting nMinimumChainWork=%s\n", chainman.MinimumChainWork().GetHex());
    155+    LogInfo("Setting nMinimumChainWork=%s", chainman.MinimumChainWork().GetHex());
    156     if (chainman.MinimumChainWork() < UintToArith256(chainman.GetConsensus().nMinimumChainWork)) {
    157         LogPrintf("Warning: nMinimumChainWork set below default value of %s\n", chainman.GetConsensus().nMinimumChainWork.GetHex());
    


    fanquake commented at 9:22 am on July 14, 2025:
    LogWarning?
  6. in src/init.cpp:1291 in fa595eb5b0 outdated
    1289         for (auto* index : node.indexes) {
    1290             index->Interrupt();
    1291             index->Stop();
    1292             if (!(index->Init() && index->StartBackgroundSync())) {
    1293-                LogPrintf("[snapshot] WARNING failed to restart index %s on snapshot chain\n", index->GetName());
    1294+                LogInfo("[snapshot] WARNING failed to restart index %s on snapshot chain", index->GetName());
    


    fanquake commented at 9:23 am on July 14, 2025:
    LogWarning?

    maflcko commented at 9:27 am on July 14, 2025:
    thx, reverted. (I’ll do the warn level in a follow-up, so that this is limited to just the info level)

    l0rinc commented at 1:36 am on July 20, 2025:
    I personally would find it simpler if we inlined every single LogPrintf call here, removed the alias and the dedicated test, and do the info/warn/error differentiation in a separate PR. I know that means we’d be touching the same lines multiple times, but in that case this PR could simply be a scripted diff with alias removal (+ line ending and __func__ and spacing fixes in separate commits) instead of having to check if we consider the text a warning or an info as well (since there are many of remaining LogPrintf calls that I would still consider info logs but weren’t migrated here for some reason.

    maflcko commented at 2:23 pm on July 24, 2025:

    instead of having to check if we consider the text a warning or an info as well (since there are many of remaining LogPrintf calls that I would still consider info logs but weren’t migrated here for some reason.

    The whole point of having log levels is that they are used correctly. Otherwise, if we don’t care, we should just close this pull (and any related ones). If we do care, we should just review it (it isn’t that hard tbh).

    As for the scope of this pull: It is only about init logs (those that happen during startup and shutdown). Missing some is harmless, because they can just be done later.


    l0rinc commented at 5:52 pm on July 24, 2025:

    The whole point of having log levels is that they are used correctly

    I wasn’t recommending any incorrect usage, was just wondering if it would simplify things if we migrated the warning/error logs before this PR, so that we can automate migration of all remaining ones and remove the LogInfo alias here. I’m also fine with it as is.

    If we do care, we should just review it

    I’m not against this change, I just don’t fully understand why some of the LogPrintf weren’t migrated, e.g.

    Missing some is harmless, because they can just be done later

    Got it, I’m fine with that as well.


    maflcko commented at 7:56 am on July 25, 2025:

    I’m not against this change, I just don’t fully understand why some of the LogPrintf weren’t migrated, e.g.

    thx, done httpserver. The others you mention are not init logs (those that happen only once during startup and shutdown), because they are called in a loop for as long as the program runs.

  7. maflcko force-pushed on Jul 14, 2025
  8. DrahtBot added the label CI failed on Jul 14, 2025
  9. maflcko force-pushed on Jul 14, 2025
  10. DrahtBot removed the label CI failed on Jul 14, 2025
  11. in src/wallet/init.cpp:98 in fa65716a87 outdated
     95         return true;
     96     }
     97 
     98     if (gArgs.GetBoolArg("-blocksonly", DEFAULT_BLOCKSONLY) && gArgs.SoftSetBoolArg("-walletbroadcast", false)) {
     99-        LogPrintf("%s: parameter interaction: -blocksonly=1 -> setting -walletbroadcast=0\n", __func__);
    100+        LogInfo("Parameter interaction: -blocksonly=1 -> setting -walletbroadcast=0");
    


    stickies-v commented at 1:17 pm on July 16, 2025:
    I think LogWarning could be appropriate here for both interactions?

    maflcko commented at 12:22 pm on July 18, 2025:

    I disagree, because:

    • All parameter interaction is (and was) info level (see also LogInfo("parameter interaction: -blocksonly=1 -> setting -maxmempool=%d\n", DEFAULT_BLOCKSONLY_MAX_MEMPOOL_SIZE_MB); in init cpp)
    • A warning is for the node operator to investigate and possibly fix. See https://github.com/bitcoin/bitcoin/blob/master/doc/developer-notes.md#logging
    • The -blocksonly docs already explain the interaction, so if someone ignores the official docs, hiding a warning in the debug log likely isn’t going to affect them

    stickies-v commented at 3:11 pm on July 18, 2025:

    All parameter interaction is (and was) info level

    Fair enough, that’s at least a good reason to not do it here but in a separate pull.

    A warning is for the node operator to investigate and possibly fix.

    That’s exactly why I was thinking it should be warning: a node operator “misconfigured” their node. It may be fine, but the node may also be behaving differently than what they expect, so best is for the node operator to investigate and fix the interaction.

    Anyway, can be marked as resolved here. Will probably open a pull later. edit: I was wrong, see below


    stickies-v commented at 4:19 pm on July 18, 2025:
    Woops, sorry. I thought these parameter interactions handled incompatible explicit user settings, but they’re only updating unset settings, in which case LogInfo is absolutely appropriate.
  12. in src/init/common.cpp:117 in fa65716a87 outdated
    114@@ -115,9 +115,9 @@ bool StartLogging(const ArgsManager& args)
    115     }
    116 
    117     if (!LogInstance().m_log_timestamps)
    


    stickies-v commented at 1:20 pm on July 16, 2025:
    nit: would be good to add braces or move to one-liner while touching this

    maflcko commented at 12:17 pm on July 18, 2025:
    the diff is already at more than 100 lines, so i wanted to keep it minimal for now
  13. stickies-v approved
  14. stickies-v commented at 1:25 pm on July 16, 2025: contributor

    ACK fa65716a878dbc0daabf1b31e832db5b230c285c

    Mostly refactor operations, with a couple of minor logging statement updates (e.g. removing function names, adding detail on which operation is started/exited, …)

  15. DrahtBot added the label Needs rebase on Jul 19, 2025
  16. in src/node/blockstorage.cpp:1239 in fa65716a87 outdated
    1231@@ -1232,17 +1232,17 @@ void ImportBlocks(ChainstateManager& chainman, std::span<const fs::path> import_
    1232             if (file.IsNull()) {
    1233                 break; // This error is logged in OpenBlockFile
    1234             }
    1235-            LogPrintf("Reindexing block file blk%05u.dat...\n", (unsigned int)nFile);
    1236+            LogInfo("Reindexing block file blk%05u.dat...", (unsigned int)nFile);
    1237             chainman.LoadExternalBlockFile(file, &pos, &blocks_with_unknown_parent);
    1238             if (chainman.m_interrupt) {
    1239-                LogPrintf("Interrupt requested. Exit %s\n", __func__);
    1240+                LogInfo("Interrupt requested. Exit reindexing.");
    


    l0rinc commented at 1:06 am on July 20, 2025:
    Would it be possible to separate the LogPrintf inlining from the __func__ and rewording changes into focused commits?

    maflcko commented at 2:36 pm on July 24, 2025:
    thx, done. (Did a rebase and then a zero-diff to split into two commits)
  17. l0rinc approved
  18. l0rinc commented at 1:43 am on July 20, 2025: contributor

    Concept ACK, thanks for the cleanup.

    I personally would prefer doing every single LogPrintf -> LogInfo inlining here in a scripted diff (so we can get rid of the alias), with follow-up commits fixing the line endings and formatting and stuff.

    And I agree that the warn/error split should be done in a separate PR where we can focus on the context (we could probably do a scripted diff for most of the lines that contain warning/error to cover most of those as well)

  19. fanquake commented at 5:08 pm on July 20, 2025: member

    I personally would prefer doing every single LogPrintf -> LogInfo inlining here in a scripted diff

    #29641.

  20. l0rinc commented at 5:32 pm on July 20, 2025: contributor

    #29641

    Yes, I’m aware - was there a discussion that I missed for why we’re not doing that instead?

  21. maflcko force-pushed on Jul 24, 2025
  22. fanquake commented at 2:29 pm on July 24, 2025: member
    ACK 26a43ed0cf6577bfa6e60b979179b0d99c2ad7db
  23. DrahtBot requested review from stickies-v on Jul 24, 2025
  24. DrahtBot requested review from l0rinc on Jul 24, 2025
  25. maflcko force-pushed on Jul 24, 2025
  26. DrahtBot removed the label Needs rebase on Jul 24, 2025
  27. in src/wallet/init.cpp:91 in fa4002b353 outdated
    87@@ -88,14 +88,14 @@ bool WalletInit::ParameterInteraction() const
    88 {
    89     if (gArgs.GetBoolArg("-disablewallet", DEFAULT_DISABLE_WALLET)) {
    90         for (const std::string& wallet : gArgs.GetArgs("-wallet")) {
    91-            LogPrintf("%s: parameter interaction: -disablewallet -> ignoring -wallet=%s\n", __func__, wallet);
    92+            LogInfo("Parameter interaction: -disablewallet -> ignoring -wallet=%s", wallet);
    


    l0rinc commented at 5:48 pm on July 24, 2025:

    Slightly unrelated question: given that WalletLogPrintf calls LogInfo now

    (which was changed in https://github.com/bitcoin/bitcoin/commit/facbcd4cef8890ae18976fb53b67ea56b3c04454#diff-bf36b7865eb69d4b0a3576d830004933c82a795d3fd73c8073c11fc2e637a5c4R259-R261), I was wondering if this is the right time to rename the method as well. I don’t mind if you think this isn’t the place.

  28. in src/init/common.cpp:118 in fa4002b353 outdated
    114@@ -115,9 +115,9 @@ bool StartLogging(const ArgsManager& args)
    115     }
    116 
    117     if (!LogInstance().m_log_timestamps)
    118-        LogPrintf("Startup time: %s\n", FormatISO8601DateTime(GetTime()));
    119-    LogPrintf("Default data directory %s\n", fs::PathToString(GetDefaultDataDir()));
    120-    LogPrintf("Using data directory %s\n", fs::PathToString(gArgs.GetDataDirNet()));
    121+        LogInfo("Startup time: %s", FormatISO8601DateTime(GetTime()));
    


    l0rinc commented at 6:01 pm on July 24, 2025:
    nit, if you touch again, please consider adding braces here to avoid any confusion caused by other surrounding logs

    maflcko commented at 7:56 am on July 25, 2025:
    thx, done
  29. in src/node/chainstate.cpp:157 in fa4002b353 outdated
    155+    LogInfo("Setting nMinimumChainWork=%s", chainman.MinimumChainWork().GetHex());
    156     if (chainman.MinimumChainWork() < UintToArith256(chainman.GetConsensus().nMinimumChainWork)) {
    157         LogPrintf("Warning: nMinimumChainWork set below default value of %s\n", chainman.GetConsensus().nMinimumChainWork.GetHex());
    158     }
    159     if (chainman.m_blockman.GetPruneTarget() == BlockManager::PRUNE_TARGET_MANUAL) {
    160-        LogPrintf("Block pruning enabled.  Use RPC call pruneblockchain(height) to manually prune block and undo files.\n");
    


    l0rinc commented at 6:04 pm on July 24, 2025:
    nit: the commit message claims This refactor does not change behavior, but we’re removing a redundant space here, which could theoretically invalidate previous log parsers. It seems fine to me to do that, but we might want to mention it in the commit message.

    maflcko commented at 7:56 am on July 25, 2025:
    thx, done
  30. l0rinc approved
  31. l0rinc commented at 6:08 pm on July 24, 2025: contributor
    ACK fa4002b3534fbd22a43b32cb24420652d12da6d2
  32. DrahtBot requested review from fanquake on Jul 24, 2025
  33. log: Remove function name from init logs
    It is redundant with -logsourcelocations and the log messages are
    clearer without it.
    
    Also, remove a double-space.
    
    Also, add braces around `if` touched in the next commit.
    
    This tiny behavior change requires a test fixup.
    fa183761cb
  34. log: [refactor] Use info level for init logs
    This refactor does not change behavior.
    face8123fd
  35. maflcko force-pushed on Jul 25, 2025
  36. stickies-v commented at 10:09 am on July 25, 2025: contributor
    re-ACK face8123fdc10549676c6679ee3225c178a7f30c
  37. DrahtBot requested review from l0rinc on Jul 25, 2025
  38. fanquake commented at 10:59 am on July 25, 2025: member
    ACK face8123fdc10549676c6679ee3225c178a7f30c
  39. fanquake merged this on Jul 25, 2025
  40. fanquake closed this on Jul 25, 2025

  41. maflcko deleted the branch on Jul 25, 2025
  42. l0rinc commented at 0:32 am on July 26, 2025: contributor

    Post-merge ACK

    It seems the post-merge build was partially cancelled for some reason, but the follow-ups passed fully πŸ‘


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-08-02 18:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me