refactor: logging: Various API improvements #34806

pull ajtowns wants to merge 8 commits into bitcoin:master from ajtowns:202603-log-niceties2 changing 70 files +146 −121
  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

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

    Reviews

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

    Conflicts

    Reviewers, this pull request conflicts with the following ones:

    • #bitcoin-core/gui/870 ([DRAFT] Expose AssumeUTXO Load Snapshot Functionality To The GUI by D33r-Gee)
    • #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)
    • #34520 (refactor: Add [[nodiscard]] to functions returning bool+mutable ref by maflcko)
    • #34514 (refactor: remove unnecessary std::move for trivially copyable types by l0rinc)
    • #34495 (Replace boost signals with minimal compatible implementation by theuni)
    • #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)
    • #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.

  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. 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.
    e526b6908d
  7. util/log: Provide util::log::NO_RATE_LIMIT to avoid rate limits a19fbe4ec5
  8. util/log: Rename LogPrintLevel_ into detail_ namespace
    After the previous commit, LogPrintLevel_ is only used to implement
    other macros.
    eff4a23bba
  9. logging: Move GetLogCategory into Logger class 607aad74d3
  10. util/log, logging: Provide ShouldDebugLog and ShouldTraceLog instead of a generic ShouldLog 3e201cc69f
  11. 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-
    df740afb39
  12. 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.
    897fb9f9a7
  13. logging: use util/log.h where possible
    Replace usage of logging.h with util/log.h where it
    suffices.
    8d118d8fe0
  14. ajtowns force-pushed on Mar 20, 2026
  15. DrahtBot removed the label Needs rebase on Mar 20, 2026

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-03-24 03:12 UTC

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