refactor: logging: Various API improvements #34806

pull ajtowns wants to merge 9 commits into bitcoin:master from ajtowns:202603-log-niceties2 changing 71 files +146 −123
  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.

    <!--021abf342d371248e50ceaed478a90ca-->

    Reviews

    See the guideline for information on the review process. A summary of reviews will appear here.

    <!--174a7506f384e20aa4161008e828411d-->

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #35084 (ipc: Support for windows support by ryanofsky)
    • #35043 (refactor: Properly return from ThreadSafeQuestion signal + btcsignals follow-ups by maflcko)
    • #35040 (Remove CNode dependency for local address functions and introduce LocalAddressManager by theuni)
    • #35011 (ci, iwyu: Fix warnings in src/script and treat them as errors by BrandonOdiwuor)
    • #34865 (logging: better use of log::Entry internally by stickies-v)
    • #34778 (logging: rewrite macros to add ratelimit option, avoid unused strprintf, clarify confusing errors by ryanofsky)
    • #34730 (util/log: Combine the warning/error log levels into a single alert level by ajtowns)
    • #34641 (node: scale default -dbcache with system RAM by l0rinc)
    • #34603 (wallet: Fix detection of symlinks on Windows by achow101)
    • #34514 (refactor: remove unnecessary std::move for trivially copyable types by l0rinc)
    • #34435 (refactor: use _MiB/_GiB consistently for byte conversions by l0rinc)
    • #34038 (logging: replace -loglevel with -trace, expose trace logging via RPC by ajtowns)
    • #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)
    • #30343 (wallet, logging: Replace WalletLogPrintf() with LogInfo() 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-->

    LLM Linter (✨ experimental)

    Possible typos and grammar issues:

    • ratelimiting -> rate limiting [“ratelimiting” in the comment appears misspelled; it should be “rate limiting” for clarity.]

    <sup>2026-04-09 17:36:08</sup>

  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. util/stdmutex: Drop StdLockGuard f622414486
  14. 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.
    c98810a4e6
  15. util/log: Provide util::log::NO_RATE_LIMIT to avoid rate limits f99e9e69b5
  16. util/log: Rename LogPrintLevel_ into detail_ namespace
    After the previous commit, LogPrintLevel_ is only used to implement
    other macros.
    155f8c9fb3
  17. logging: Move GetLogCategory into Logger class 6c076b82ca
  18. util/log, logging: Provide ShouldDebugLog and ShouldTraceLog instead of a generic ShouldLog 722bd6dba7
  19. 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-
    89eafa0983
  20. 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.
    dab1393b9f
  21. logging: use util/log.h where possible
    Replace usage of logging.h with util/log.h where it
    suffices.
    91f35ea257
  22. ajtowns force-pushed on Apr 9, 2026
  23. DrahtBot removed the label Needs rebase on Apr 9, 2026
Contributors

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-04-22 06:12 UTC

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