Skip to content

refactor: logging: Various API improvements#34806

Open
ajtowns wants to merge 8 commits intobitcoin:masterfrom
ajtowns:202603-log-niceties2
Open

refactor: logging: Various API improvements#34806
ajtowns wants to merge 8 commits intobitcoin:masterfrom
ajtowns:202603-log-niceties2

Conversation

@ajtowns
Copy link
Contributor

@ajtowns ajtowns commented Mar 11, 2026

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.

ajtowns added 8 commits March 12, 2026 00:19
We should not be logging while shrinking the debug file, so make sure
that's true by using our mutex.
After the previous commit, LogPrintLevel_ is only used to implement
other macros.
-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-
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.
Replace usage of logging.h with util/log.h where it
suffices.
@DrahtBot
Copy link
Contributor

DrahtBot commented Mar 11, 2026

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)
  • #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)
  • #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)
  • #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)
  • #33215 (Fix compatibility with -debuglogfile command-line option by hebasto)
  • #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.

@ajtowns
Copy link
Contributor Author

ajtowns commented Mar 11, 2026

Split off from #34038

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants