ajtowns
commented at 12:56 AM on May 22, 2026:
contributor
Followup of #28318, #34038, and #34806 to simplify and optimize the logging-disabled path for LogTrace().
Removes the global log level (m_log_level) and the unordered_map from category to level (m_category_log_levels) in favour of a single atomic<uint64_t> m_trace_categories, and reduces ShouldDebugLog and ShouldTraceLog to lock-free checks on a single atomic. Also makes Enabled() lock-free, to waste a little less time in the case where debugging is completely disabled.
Does a bit of clean up as well:
guards m_file_path and provides accessors
makes other configuration variables atomic, rather than "write-before-createing-threads-then-treat-as-read-only"
See the guideline and AI policy for information on the review process.
A summary of reviews will appear here.
<!--174a7506f384e20aa4161008e828411d-->
Conflicts
Reviewers, this pull request conflicts with the following ones:
#36268 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36268.svg"></sub> (refactor: prune unused semi-colons by fanquake)
#36257 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36257.svg"></sub> (qa: assert_equals -> assert_true/assert_false by hodlinator)
#36074 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/36074.svg"></sub> (scripted-diff: [test] Add util/check.h includes for assertions by maflcko)
#35911 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35911.svg"></sub> (Warn on and add missing [[noreturn]] by fanquake)
#35387 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35387.svg"></sub> (logging: make trace logging easily usable by ryanofsky)
#34775 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/34775.svg"></sub> (kernel: allow only one global logging connection by stickies-v)
#10102 <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/10102.svg"></sub> (Multiprocess bitcoin 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-->
ajtowns
commented at 1:00 AM on May 22, 2026:
contributor
DrahtBot added the label CI failed on May 22, 2026
DrahtBot removed the label CI failed on May 22, 2026
DrahtBot added the label Needs rebase on Jun 22, 2026
logging: replace -loglevel arg with -trace
Previously, trace logging for a category was enabled by saying "-debug=net
-loglevel=net:trace" and saying "-loglevel=net:trace" (without "-debug"
or "-debug=net") would silently do nothing. Simplify this so that
"-debug=net" enables debug logging for net and "-trace=net" enables
both debug and trace logging for net.
Note that "-nodebug" and "-notrace" only disable previous "-debug=xxx" and
"-trace=yyy" arguments, so "-debug=mempool -trace=net -nodebug" will cancel
"-debug=mempool", but will still include both debug and trace logs for net.
2708138613
rpc: Update logging RPC to support trace level debugging
Also changes the output format, to distinguish debug/trace levels.
Provides `-deprecatedrpc=logging` if old output format is needed.
Co-Authored-By: stickies-v <stickies-v@protonmail.com>
730154e28c
[doc] Release notes for user-visible logging changes649b0503ad
logging: replace global and category log levels with atomic int
Since we have reduced how much log levels can be configured (error,
warning and info are always logged; and only debug and trace levels can
be disabled), we only need two bits per category to store the information.
We can do this with two atomic ints, one for whether -debug is enabled,
and the other for whether -trace is enabled.
This allows `WillLogCategoryLevel` to avoid taking a mutex, potentially
allowing for better performance in the event that multiple threads are
running many LogDebug(..) statements over categories that do not have
-debug enabled (or LogTrace/-trace).
0572c28fe3
logging: Make sure BCLog::Logger members are atomic or guardedb57b2169e0
logging: Make Enabled() lock-free
Add m_any_print_callbacks as a cache for !m_print_callbacks.empty(),
and make m_buffered atomic. Makes the Log functions almost completely
free when logging is completely disabled (though unlike for LogDebug
when the category is disabled, arguments are still evaluated).
9ff433e935
[move-only] logging: Move Logger member variables togethereadc695e7f
logging: Replace Enable/Trace/DisableCategory(str) with SetCategoryLogLevel(str, level)91c03acd98
logging: Drop unused SetCategoryLogLevel(str,str)a59b95ba3c
logging: Drop Enable/Trace/DisableCategory aliases79c1d41159
logging: Drop WillLogCategory* in favour of Logger::ShouldDebugLog and ShouldTraceLog3691d4302d
util/log.h: Move internal functions into detail namespacea9006aa17e
logging: Make some functions static
LogCategoriesString and LogLevelsString don't need access to an object,
so make them static.
2d4996e20e
util/log.h: Make debug/trace enablement global and atomic
Simplifies the util/log.h API so that log enablement does not require
indirection and `ShouldDebugLog` and `ShouldTraceLog` can be fully
inlined at logging call sites.
The category bitmasks become constinit atomic globals, so any usage is
valid from any context, including dynamic initialization of other static
variables, and avoids any dependency on the exact implementation of
`util::log::Log()`.
The redundant `BCLog::Logger::Should*Log` functions are removed.
36586ec1b3
ajtowns force-pushed on Oct 23, 2026
DrahtBot removed the label Needs rebase on Oct 23, 2026
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-10-31 11:51 UTC
This site is hosted by @0xB10C More mirrored repositories can be found on mirror.b10c.me