refactor: logging: Various API improvements #34806

pull ajtowns wants to merge 9 commits into bitcoin:master from ajtowns:202603-log-niceties2 changing 71 files +151 −122
  1. ajtowns commented at 4:45 PM on March 11, 2026: contributor

    ShrinkDebugFile now takes the logging mutex for its entire run; though it's only called in init so shouldn't have any races in the first place.

    Adds a NO_RATE_LIMIT tag that can be used with info/warning/error logs to avoid rate-limiting. This allows LogPrintLevel_ to be restricted to being an internal API.

    The GetLogCategory function is moved out of the global namespace.

    ShouldLog is split into separate ShouldDebugLog and ShouldTraceLog so that filtering checks are somewhat more enforced via function signature checks.

    Redundant LogAcceptCategory function is removed.

    More files are pointed at util/log.h instead of logging.h.

  2. DrahtBot added the label Refactoring on Mar 11, 2026
  3. DrahtBot commented at 4:46 PM on March 11, 2026: contributor

    <!--e57a25ab6845829454e8d69fc972939a-->

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

    <!--006a51241073e994b41acfe9ec718e94-->

    Code Coverage & Benchmarks

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

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline for information on the review process.

    Type Reviewers
    ACK sedited

    If your review is incorrectly listed, please copy-paste <code>&lt;!--meta-tag:bot-skip--&gt;</code> into the comment that the bot should ignore.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #35205 (node,kernel: share dbcache default sizing by l0rinc)
    • #35201 (Refactor: Updated signMessage to use util::Expected and removed SigningResult::OK by kevkevinpal)
    • #35105 (Refactor: Updated TransactionError to use util::Expected and removed TransactionError:OK by kevkevinpal)
    • #35084 (ipc: Support for windows support by ryanofsky)
    • #35043 (refactor: Properly return from ThreadSafeQuestion signal + btcsignals follow-ups by maflcko)
    • #35037 (ipc: support per-address max-connections options on -ipcbind by enirox001)
    • #35011 (ci, iwyu: Fix warnings in src/script and treat them as errors by BrandonOdiwuor)
    • #34995 (ci, iwyu: Fix warnings in src/common and treat them as errors by hebasto)
    • #34909 (wallet, refactor: modularise wallet by extracting out legacy wallet migration by rkrux)
    • #34778 (logging: rewrite macros to add ratelimit option, avoid unused strprintf, clarify confusing errors by ryanofsky)
    • #34533 (wallet: resubmit transactions with private broadcast if enabled by vasild)
    • #34514 (refactor: remove unnecessary std::move for a few trivially copyable types by l0rinc)
    • #34075 (fees: Introduce Mempool Based Fee Estimation to reduce overestimation by ismaelsadeeq)
    • #34038 (logging: replace -loglevel with -trace, expose trace logging via RPC by ajtowns)
    • #33966 (refactor: disentangle miner startup defaults from runtime options by Sjors)
    • #33922 (mining: add getMemoryLoad() and track template non-mempool memory footprint by Sjors)
    • #33727 (zmq: Log bind error at Error level, abort startup on init error by isrod)
    • #33421 (node: add BlockTemplateCache by ismaelsadeeq)
    • #33117 (Interfaces: Expose UTXO Snapshot Loading and Add Progress Notifications by D33r-Gee)
    • #32387 (ipc: add windows support by ryanofsky)
    • #31260 (scripted-diff: Type-safe settings retrieval by ryanofsky)
    • #29256 (log, refactor: Allow log macros to accept context arguments by ryanofsky)

    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.

    <!--5faf32d7da4f0f540f40219e4f7537a3-->

  4. ajtowns commented at 5:08 PM on March 11, 2026: contributor

    Split off from #34038

  5. DrahtBot added the label Needs rebase on Mar 20, 2026
  6. ajtowns force-pushed on Mar 20, 2026
  7. DrahtBot removed the label Needs rebase on Mar 20, 2026
  8. ajtowns force-pushed on Mar 24, 2026
  9. DrahtBot added the label Needs rebase on Mar 31, 2026
  10. ajtowns force-pushed on Apr 2, 2026
  11. DrahtBot removed the label Needs rebase on Apr 2, 2026
  12. DrahtBot added the label Needs rebase on Apr 9, 2026
  13. ajtowns force-pushed on Apr 9, 2026
  14. DrahtBot removed the label Needs rebase on Apr 9, 2026
  15. DrahtBot added the label Needs rebase on Apr 23, 2026
  16. util/stdmutex: Drop StdLockGuard 904c0d07bb
  17. logging: Protect ShrinkDebugFile by m_cs
    We should not be logging while shrinking the debug file, so make sure
    that's true by using our mutex.
    b408c2cde2
  18. util/log: Provide util::log::NO_RATE_LIMIT to avoid rate limits aae93d033a
  19. util/log: Rename LogPrintLevel_ into detail_ namespace
    After the previous commit, LogPrintLevel_ is only used to implement
    other macros.
    8d1edeb3fa
  20. logging: Move GetLogCategory into Logger class f7cdb5e36d
  21. util/log, logging: Provide ShouldDebugLog and ShouldTraceLog instead of a generic ShouldLog 12035b9a73
  22. scripted-diff: logging: Drop LogAcceptCategory
    -BEGIN VERIFY SCRIPT-
    sed -i 's/LogAcceptCategory(\(.*\), [a-zA-Z:]*::Level::Debug)/util::log::ShouldDebugLog(\1)/g' $(git grep -l LogAcceptCategory -- '*.cpp')
    sed -i 's/LogAcceptCategory(\(.*\), [a-zA-Z:]*::Level::Trace)/util::log::ShouldTraceLog(\1)/g' $(git grep -l LogAcceptCategory -- '*.cpp')
    sed -i '/Return true if log accepts specified category/,/^$/d' src/logging.h
    -END VERIFY SCRIPT-
    8bbf99479b
  23. IWYU fixes
    Add missing includes of logging.h in preparation for the next commit,
    switching to util/log.h. Also removes some unnecessary util/check.h
    includes that CI complains about.
    2834ee6a23
  24. logging: use util/log.h where possible
    Replace usage of logging.h with util/log.h where it
    suffices.
    2077e57eb0
  25. ajtowns force-pushed on Apr 23, 2026
  26. DrahtBot removed the label Needs rebase on Apr 23, 2026
  27. DrahtBot added the label CI failed on Apr 23, 2026
  28. DrahtBot removed the label CI failed on Apr 23, 2026
  29. sedited approved
  30. sedited commented at 10:57 AM on May 11, 2026: contributor

    lgtm ACK 2077e57eb0107acfeb09846899c7e7ae7f77014e

    This is bit of a laundry list, and the conflicts are unfortunate, but better to get this done sooner rather than later.


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: 2026-05-12 15:12 UTC

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