logging: streamline Logger state and drop redundant methods #35322

Open
ryanofsky wants to merge 13 commits from pr/levels into master AGit
ryanofsky commented 2026-05-19 13:55:05 +00:00 (Migrated from github.com)

Problem: The Logger class currently tracks enabled log messages using three separate fields:

  • m_categories — bitmask of enabled log categories
  • m_log_level — global log level threshold
  • m_category_log_levels — hash map of per-category level overrides

This representation is confusing and redundant. Bitcoin Core has only ~30 log categories and 2 conditional log levels, so a mutex-protected hash map, a bitset, and a separate global level are unnecessary. The added complexity is also harmful: it makes the code harder to follow, and basic operations like setting a category's level require coordinating multiple fields and method calls.

Solution: This PR streamlines the Logger class without changing behavior, replacing the three fields with two atomics: one bitmask for each conditional log level (Debug and Trace). Each bitmask records which categories are enabled at that level.

This allows the following methods to be dropped: EnableCategory, DisableCategory, WillLogCategory, LogLevel, SetLogLevel, GetCategoryMask, AddCategoryLogLevel. The remaining SetCategoryLogLevel and WillLogCategoryLevel methods are now self-contained.

Behavior note: This is a behavior-preserving refactor with one exception: categories dynamically enabled at runtime through the logging RPC or the kernel btck_logging_* API are now always enabled at Debug level, even if -loglevel=trace or its kernel equivalent was set at startup. This is unlikely to matter in practice. Very little LogTrace logging currently exists, and both APIs are being reworked in bitcoin/bitcoin#34038 and bitcoin/bitcoin#34374. The -loglevel option otherwise continues to work as before when categories are not changed at runtime.

**Problem:** The `Logger` class currently tracks enabled log messages using three separate fields: - `m_categories` — bitmask of enabled log categories - `m_log_level` — global log level threshold - `m_category_log_levels` — hash map of per-category level overrides This representation is confusing and redundant. Bitcoin Core has only ~30 log categories and 2 conditional log levels, so a mutex-protected hash map, a bitset, and a separate global level are unnecessary. The added complexity is also harmful: it makes the code harder to follow, and basic operations like setting a category's level require coordinating multiple fields and method calls. **Solution:** This PR streamlines the `Logger` class without changing behavior, replacing the three fields with two atomics: one bitmask for each conditional log level (`Debug` and `Trace`). Each bitmask records which categories are enabled at that level. This allows the following methods to be dropped: `EnableCategory`, `DisableCategory`, `WillLogCategory`, `LogLevel`, `SetLogLevel`, `GetCategoryMask`, `AddCategoryLogLevel`. The remaining `SetCategoryLogLevel` and `WillLogCategoryLevel` methods are now self-contained. **Behavior note:** This is a behavior-preserving refactor with one exception: categories dynamically enabled at runtime through the `logging` RPC or the kernel `btck_logging_*` API are now always enabled at Debug level, even if `-loglevel=trace` or its kernel equivalent was set at startup. This is unlikely to matter in practice. Very little `LogTrace` logging currently exists, and both APIs are being reworked in bitcoin/bitcoin#34038 and bitcoin/bitcoin#34374. The `-loglevel` option otherwise continues to work as before when categories are not changed at runtime.
DrahtBot commented 2026-05-19 13:55:14 +00:00 (Migrated from github.com)

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

External sites

Reviews

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

Conflicts

Reviewers, this pull request conflicts with the following ones:

  • #35387 (logging: make trace logging easily usable by ryanofsky)
  • #35355 (Use atomics for determining whether trace logging is enabled by ajtowns)
  • #34778 (logging: rewrite macros to enforce restrictions at compile-time, improve efficiency and usability by ryanofsky)
  • #34038 (logging: replace -loglevel with -trace, expose trace logging via RPC by ajtowns)
  • #29256 (log, refactor: Allow log macros to accept context arguments by ryanofsky)
  • #17783 (common: Disallow calling IsArgSet() on ALLOW_LIST options by ryanofsky)
  • #17580 (refactor: Add ALLOW_LIST flags and enforce usage in CheckArgFlags 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.

<!--e57a25ab6845829454e8d69fc972939a--> The following sections might be updated with supplementary metadata relevant to reviewers and maintainers. <!--006a51241073e994b41acfe9ec718e94--> ### External sites * Code coverage & benchmarks: https://corecheck.dev/bitcoin/bitcoin/pulls/35322 * Ralph review <img src=https://review.fish.foo/assets/bitcoin/bitcoin/35322.png alt="Ralph review status"> https://git.fish.foo/bitcoin/bitcoin/pulls/35322#author-ralph <!--021abf342d371248e50ceaed478a90ca--> ### Reviews See [the guideline](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#code-review) and [AI policy](https://github.com/bitcoin/bitcoin/blob/master/doc/AI_POLICY.md) for information on the review process. A summary of reviews will appear here. <!--174a7506f384e20aa4161008e828411d--> ### Conflicts Reviewers, this pull request conflicts with the following ones: * [#35387](https://github.com/bitcoin/bitcoin/pull/35387) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35387.svg"></sub> (logging: make trace logging easily usable by ryanofsky) * [#35355](https://github.com/bitcoin/bitcoin/pull/35355) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/35355.svg"></sub> (Use atomics for determining whether trace logging is enabled by ajtowns) * [#34778](https://github.com/bitcoin/bitcoin/pull/34778) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/34778.svg"></sub> (logging: rewrite macros to enforce restrictions at compile-time, improve efficiency and usability by ryanofsky) * [#34038](https://github.com/bitcoin/bitcoin/pull/34038) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/34038.svg"></sub> (logging: replace -loglevel with -trace, expose trace logging via RPC by ajtowns) * [#29256](https://github.com/bitcoin/bitcoin/pull/29256) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/29256.svg"></sub> (log, refactor: Allow log macros to accept context arguments by ryanofsky) * [#17783](https://github.com/bitcoin/bitcoin/pull/17783) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/17783.svg"></sub> (common: Disallow calling IsArgSet() on ALLOW_LIST options by ryanofsky) * [#17580](https://github.com/bitcoin/bitcoin/pull/17580) <sub><img src="https://drahtbot.space/ack_count/bitcoin/bitcoin/17580.svg"></sub> (refactor: Add ALLOW_LIST flags and enforce usage in CheckArgFlags 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-->
l0rinc (Migrated from github.com) requested changes 2026-05-20 08:59:42 +00:00
l0rinc (Migrated from github.com) commented 2026-05-20 08:58:56 +00:00

There's a single commit here with a lot of changes that don't look closely related.
I don't have a strong opinion about logging, but it's obviously important to others so I don't mind reviewing it - though in this current state I can't do that meaningfully.
If you think it's worth it, could you please split this into smaller, more focused commits (maybe multiple PRs, since the title already suggests it's hard to properly describe the goal of the changes)?

There's a single commit here with a lot of changes that don't look closely related. I don't have a strong opinion about logging, but it's obviously important to others so I don't mind reviewing it - though in this current state I can't do that meaningfully. If you think it's worth it, could you please split this into smaller, more focused commits (maybe multiple PRs, since the title already suggests it's hard to properly describe the goal of the changes)?
ryanofsky (Migrated from github.com) reviewed 2026-05-20 10:24:11 +00:00
ryanofsky (Migrated from github.com) commented 2026-05-20 10:24:11 +00:00

re: https://github.com/bitcoin/bitcoin/pull/35322#discussion_r3272563675

I don't mind reviewing it - though in this current state I can't do that meaningfully

Thanks for looking at this! This PR is a fairly small change: only +77/-124 lines excluding tests. But I appreciate it could be pretty difficult to understand if you are coming in cold and don't know where to begin.

I think it should be possible to split the PR up and I'll experiment with this. (Here is a branch claude made which splits the PR into two commits. pr/levels-explain. It looks ok but I want to verify.)

If I can give a review tip for the current PR, it would be to first look at the new SetCategoryLogLevel & WillLogCategoryLevel implementations and understand how they use the m_levels array to determine what to log and not log.

After you understand those two methods, you basically understand the whole PR because it is just updating the rest of the code to call those methods.

it's hard to properly describe the goal of the changes

Let me know if I can help with this, I do hope the description is clear.

re: https://github.com/bitcoin/bitcoin/pull/35322#discussion_r3272563675 > I don't mind reviewing it - though in this current state I can't do that meaningfully Thanks for looking at this! This PR is a fairly small change: only +77/-124 lines excluding tests. But I appreciate it could be pretty difficult to understand if you are coming in cold and don't know where to begin. I think it should be possible to split the PR up and I'll experiment with this. (Here is a branch claude made which splits the PR into two commits. [pr/levels-explain](https://github.com/ryanofsky/bitcoin/commits/pr/levels-explain). It looks ok but I want to verify.) If I can give a review tip for the current PR, it would be to first look at the new [`SetCategoryLogLevel & WillLogCategoryLevel`](https://github.com/ryanofsky/bitcoin/blob/ccd90a75125586f4f5a03fda5477738b10745d20/src/logging.cpp#L128-L145) implementations and understand how they use the [m_levels](https://github.com/ryanofsky/bitcoin/blob/ccd90a75125586f4f5a03fda5477738b10745d20/src/logging.h#L147-L151) array to determine [what to log](https://github.com/ryanofsky/bitcoin/blob/ccd90a75125586f4f5a03fda5477738b10745d20/src/logging.h#L230-L236) and not log. After you understand those two methods, you basically understand the whole PR because it is just updating the rest of the code to call those methods. > it's hard to properly describe the goal of the changes Let me know if I can help with this, I do hope the description is clear.
l0rinc (Migrated from github.com) requested changes 2026-05-22 14:56:43 +00:00
l0rinc (Migrated from github.com) left a comment

I tried splitting this locally to make review easier. I still think the current version mixes several separate concerns, and I have questions about whether grouping levels and categories this way is the right model, since it seems to apply a general rule to behavior that is currently quite specific and ad hoc.

Left comments on splitting the commit into smaller reviewable steps, clarifying or preserving behavior changes, and adding focused tests for intentional changes.

Main concerns are startup/kernel logging semantics, runtime-enable behavior coverage, and making the new m_levels model easier to reason about.

I tried splitting this locally to make review easier. I still think the current version mixes several separate concerns, and I have questions about whether grouping levels and categories this way is the right model, since it seems to apply a general rule to behavior that is currently quite specific and ad hoc. Left comments on splitting the commit into smaller reviewable steps, clarifying or preserving behavior changes, and adding focused tests for intentional changes. Main concerns are startup/kernel logging semantics, runtime-enable behavior coverage, and making the new `m_levels` model easier to reason about.
l0rinc (Migrated from github.com) commented 2026-05-22 14:36:36 +00:00

This looks similar to the earlier concern. Isn't this a behavior change as well? Previously, setting a category level did not enable the category. Now it looks like setting the level also enables it. Should we adjust this to match the old behavior?
I see the tests don't always keep the enable-first-set-level after, but maybe we can do that:

diff --git a/src/test/kernel/test_kernel.cpp b/src/test/kernel/test_kernel.cpp
--- a/src/test/kernel/test_kernel.cpp	(revision 06d9f340624c880883fba2b03aeab1b74d8812a8)
+++ b/src/test/kernel/test_kernel.cpp	(revision c9516e72f9c26f76aacc510e9d39448291fc2994)
@@ -636,6 +636,7 @@
     };
 
     logging_set_options(logging_options);
+    logging_enable_category(LogCategory::BENCH);
     logging_set_level_category(LogCategory::BENCH, LogLevel::TRACE_LEVEL);
     logging_disable_category(LogCategory::BENCH);
     logging_enable_category(LogCategory::VALIDATION);
@@ -643,8 +644,8 @@
 
     // Check that connecting, connecting another, and then disconnecting and connecting a logger again works.
     {
-        logging_set_level_category(LogCategory::KERNEL, LogLevel::TRACE_LEVEL);
         logging_enable_category(LogCategory::KERNEL);
+        logging_set_level_category(LogCategory::KERNEL, LogLevel::TRACE_LEVEL);
         Logger logger{std::make_unique<TestLog>()};
         Logger logger_2{std::make_unique<TestLog>()};
     }
This looks similar to the earlier concern. Isn't this a behavior change as well? Previously, setting a category level did not enable the category. Now it looks like setting the level also enables it. Should we adjust this to match the old behavior? I see the tests don't always keep the enable-first-set-level after, but maybe we can do that: ```patch diff --git a/src/test/kernel/test_kernel.cpp b/src/test/kernel/test_kernel.cpp --- a/src/test/kernel/test_kernel.cpp (revision 06d9f340624c880883fba2b03aeab1b74d8812a8) +++ b/src/test/kernel/test_kernel.cpp (revision c9516e72f9c26f76aacc510e9d39448291fc2994) @@ -636,6 +636,7 @@ }; logging_set_options(logging_options); + logging_enable_category(LogCategory::BENCH); logging_set_level_category(LogCategory::BENCH, LogLevel::TRACE_LEVEL); logging_disable_category(LogCategory::BENCH); logging_enable_category(LogCategory::VALIDATION); @@ -643,8 +644,8 @@ // Check that connecting, connecting another, and then disconnecting and connecting a logger again works. { - logging_set_level_category(LogCategory::KERNEL, LogLevel::TRACE_LEVEL); logging_enable_category(LogCategory::KERNEL); + logging_set_level_category(LogCategory::KERNEL, LogLevel::TRACE_LEVEL); Logger logger{std::make_unique<TestLog>()}; Logger logger_2{std::make_unique<TestLog>()}; } ```
l0rinc (Migrated from github.com) commented 2026-05-22 13:44:08 +00:00

This loop has dual behavior that needed extra explanation in the header. Maybe we could make it more obvious via code instead:

void BCLog::Logger::SetCategoryLogLevel(CategoryMask category, BCLog::Level level)
{
    auto level_it{m_levels.begin()};
    for (size_t i{0}; level_it != m_levels.end() && i < size_t(level); ++i, ++level_it) {
        level_it->fetch_and(~category, std::memory_order_relaxed);
    }
    for (; level_it != m_levels.end(); ++level_it) {
        level_it->fetch_or(category, std::memory_order_relaxed);
    }
}

But even this seems excessive if indeed the only phase transitions are:

  Set Trace -> Trace mask on, Debug mask on
  Set Debug -> Trace mask off, Debug mask on
  Set Info  -> Trace mask off, Debug mask off
This loop has dual behavior that needed extra explanation in the header. Maybe we could make it more obvious via code instead: ```C++ void BCLog::Logger::SetCategoryLogLevel(CategoryMask category, BCLog::Level level) { auto level_it{m_levels.begin()}; for (size_t i{0}; level_it != m_levels.end() && i < size_t(level); ++i, ++level_it) { level_it->fetch_and(~category, std::memory_order_relaxed); } for (; level_it != m_levels.end(); ++level_it) { level_it->fetch_or(category, std::memory_order_relaxed); } } ``` But even this seems excessive if indeed the only phase transitions are: ``` Set Trace -> Trace mask on, Debug mask on Set Debug -> Trace mask off, Debug mask on Set Info -> Trace mask off, Debug mask off ```
Lines 143-145
l0rinc (Migrated from github.com) commented 2026-05-22 11:51:14 +00:00

This seems like a code smell (even though it was similar before). Wouldn't the categories already return the same value here - Is this an optimization? So if info has BCLog::LogFlags::ALL it will take this branch, but if debug has the same it will take the next line?

This seems like a code smell (even though it was similar before). Wouldn't the categories already return the same value here - Is this an optimization? So if `info` has `BCLog::LogFlags::ALL` it will take this branch, but if `debug` has the same it will take the next line?
l0rinc (Migrated from github.com) commented 2026-05-21 11:03:06 +00:00

This looks like save/restore plumbing for tests, not part of the core representation swap. Could it be split into the commit where the test fixtures first need to snapshot the level masks?

diff --git a/src/logging.cpp b/src/logging.cpp
index 6e24f2d8d9..3330ad9703 100644
--- a/src/logging.cpp
+++ b/src/logging.cpp
@@ -144,6 +144,15 @@ bool BCLog::Logger::WillLogCategoryLevel(BCLog::LogFlags category, BCLog::Level
     return (m_levels[static_cast<size_t>(level)].load(std::memory_order_relaxed) & category) != 0;
 }
 
+BCLog::Logger::LogLevels BCLog::Logger::GetLogLevels() const
+{
+    LogLevels snapshot;
+    for (size_t i = 0; i < m_levels.size(); ++i) {
+        snapshot[i] = m_levels[i].load(std::memory_order_relaxed);
+    }
+    return snapshot;
+}
+
 bool BCLog::Logger::SetLogLevel(std::string_view level_str)
 {
     const auto level{GetLogLevel(level_str)};
diff --git a/src/logging.h b/src/logging.h
index 94eaeeac95..07a20dd1b9 100644
--- a/src/logging.h
+++ b/src/logging.h
@@ -244,10 +244,10 @@ namespace BCLog {
         void AddCategoryLogLevel(LogFlags category, Level level) { SetCategoryLogLevel(category, level); }
 
         Level LogLevel() const { return DEFAULT_LOG_LEVEL; }
-        void SetLogLevel(Level level) { SetCategoryLogLevel(GetCategoryMask(), level); }
+        void SetLogLevel(Level level) { SetCategoryLogLevel(GetLogLevels().back(), level); }
         bool SetLogLevel(std::string_view level);
 
-        CategoryMask GetCategoryMask() const { return m_levels[static_cast<size_t>(Level::Debug)].load(std::memory_order_relaxed); }
+        CategoryMask GetCategoryMask() const { return GetLogLevels().back(); }
 
         void EnableCategory(LogFlags flag) { SetCategoryLogLevel(flag, BCLog::Level::Debug); }
         bool EnableCategory(std::string_view str);
@@ -275,6 +275,11 @@ namespace BCLog {
         //! Returns the string representation of a log level.
         static std::string LogLevelToStr(BCLog::Level level);
 
+        //! Snapshot type for the per-level category bitmask array (non-atomic, for save/restore).
+        using LogLevels = std::array<CategoryMask, static_cast<size_t>(UNCONDITIONAL_LOG_LEVEL)>;
+        //! Returns a snapshot of the current per-level category bitmasks.
+        LogLevels GetLogLevels() const;
+
         bool DefaultShrinkDebugFile() const { return !WillLogCategoryLevel(BCLog::ALL, BCLog::Level::Debug); }
     };
This looks like save/restore plumbing for tests, not part of the core representation swap. Could it be split into the commit where the test fixtures first need to snapshot the level masks? ```patch diff --git a/src/logging.cpp b/src/logging.cpp index 6e24f2d8d9..3330ad9703 100644 --- a/src/logging.cpp +++ b/src/logging.cpp @@ -144,6 +144,15 @@ bool BCLog::Logger::WillLogCategoryLevel(BCLog::LogFlags category, BCLog::Level return (m_levels[static_cast<size_t>(level)].load(std::memory_order_relaxed) & category) != 0; } +BCLog::Logger::LogLevels BCLog::Logger::GetLogLevels() const +{ + LogLevels snapshot; + for (size_t i = 0; i < m_levels.size(); ++i) { + snapshot[i] = m_levels[i].load(std::memory_order_relaxed); + } + return snapshot; +} + bool BCLog::Logger::SetLogLevel(std::string_view level_str) { const auto level{GetLogLevel(level_str)}; diff --git a/src/logging.h b/src/logging.h index 94eaeeac95..07a20dd1b9 100644 --- a/src/logging.h +++ b/src/logging.h @@ -244,10 +244,10 @@ namespace BCLog { void AddCategoryLogLevel(LogFlags category, Level level) { SetCategoryLogLevel(category, level); } Level LogLevel() const { return DEFAULT_LOG_LEVEL; } - void SetLogLevel(Level level) { SetCategoryLogLevel(GetCategoryMask(), level); } + void SetLogLevel(Level level) { SetCategoryLogLevel(GetLogLevels().back(), level); } bool SetLogLevel(std::string_view level); - CategoryMask GetCategoryMask() const { return m_levels[static_cast<size_t>(Level::Debug)].load(std::memory_order_relaxed); } + CategoryMask GetCategoryMask() const { return GetLogLevels().back(); } void EnableCategory(LogFlags flag) { SetCategoryLogLevel(flag, BCLog::Level::Debug); } bool EnableCategory(std::string_view str); @@ -275,6 +275,11 @@ namespace BCLog { //! Returns the string representation of a log level. static std::string LogLevelToStr(BCLog::Level level); + //! Snapshot type for the per-level category bitmask array (non-atomic, for save/restore). + using LogLevels = std::array<CategoryMask, static_cast<size_t>(UNCONDITIONAL_LOG_LEVEL)>; + //! Returns a snapshot of the current per-level category bitmasks. + LogLevels GetLogLevels() const; + bool DefaultShrinkDebugFile() const { return !WillLogCategoryLevel(BCLog::ALL, BCLog::Level::Debug); } }; ```
l0rinc (Migrated from github.com) commented 2026-05-21 08:41:56 +00:00

Could this naming cleanup be split before the atomic-mask change?
The current code already has one threshold that means "levels at or above this always log". Giving that threshold a shared name first would make the later mask change smaller, and the startup parsing checks could use the same name instead of hardcoding Level::Info.

diff --git a/src/logging.cpp b/src/logging.cpp
index 3373063c05..e0c2b2cef2 100644
--- a/src/logging.cpp
+++ b/src/logging.cpp
@@ -21,7 +21,6 @@ using util::Join;
 using util::RemovePrefixView;
 
 const char * const DEFAULT_DEBUGLOGFILE = "debug.log";
-constexpr auto MAX_USER_SETABLE_SEVERITY_LEVEL{BCLog::Level::Info};
 
 BCLog::Logger& LogInstance()
 {
@@ -162,7 +161,7 @@ bool BCLog::Logger::WillLogCategoryLevel(BCLog::LogFlags category, BCLog::Level
 {
     // Log messages at Info, Warning and Error level unconditionally, so that
     // important troubleshooting information doesn't get lost.
-    if (level >= BCLog::Level::Info) return true;
+    if (level >= BCLog::UNCONDITIONAL_LOG_LEVEL) return true;
 
     if (!WillLogCategory(category)) return false;
 
@@ -263,7 +262,7 @@ static std::string LogCategoryToStr(BCLog::LogFlags category)
     return it->second;
 }
 
-static std::optional<BCLog::Level> GetLogLevel(std::string_view level_str)
+std::optional<BCLog::Level> BCLog::Logger::GetLogLevel(std::string_view level_str)
 {
     if (level_str == "trace") {
         return BCLog::Level::Trace;
@@ -586,7 +585,7 @@ bool BCLog::LogRateLimiter::Stats::Consume(uint64_t bytes)
 bool BCLog::Logger::SetLogLevel(std::string_view level_str)
 {
     const auto level = GetLogLevel(level_str);
-    if (!level.has_value() || level.value() > MAX_USER_SETABLE_SEVERITY_LEVEL) return false;
+    if (!level.has_value() || level.value() > BCLog::UNCONDITIONAL_LOG_LEVEL) return false;
     m_log_level = level.value();
     return true;
 }
@@ -597,7 +596,7 @@ bool BCLog::Logger::SetCategoryLogLevel(std::string_view category_str, std::stri
     if (!flag) return false;
 
     const auto level = GetLogLevel(level_str);
-    if (!level.has_value() || level.value() > MAX_USER_SETABLE_SEVERITY_LEVEL) return false;
+    if (!level.has_value() || level.value() > BCLog::UNCONDITIONAL_LOG_LEVEL) return false;
 
     STDLOCK(m_cs);
     m_category_log_levels[*flag] = level.value();
diff --git a/src/logging.h b/src/logging.h
index 67f5d6ef00..041e341d3a 100644
--- a/src/logging.h
+++ b/src/logging.h
@@ -62,6 +62,8 @@ struct LogCategory {
 
 namespace BCLog {
     constexpr auto DEFAULT_LOG_LEVEL{Level::Debug};
+    //! Log messages at this severity level and above are always emitted regardless of category settings.
+    constexpr auto UNCONDITIONAL_LOG_LEVEL{Level::Info};
     constexpr size_t DEFAULT_MAX_LOG_BUFFER{1'000'000}; // buffer up to 1MB of log data prior to StartLogging
     constexpr uint64_t RATELIMIT_MAX_BYTES{1_MiB}; // maximum number of bytes per source location that can be logged within the RATELIMIT_WINDOW
     constexpr auto RATELIMIT_WINDOW{1h}; // time window after which log ratelimit stats are reset
@@ -271,6 +273,8 @@ namespace BCLog {
         //! Returns a string with all user-selectable log levels.
         std::string LogLevelsString() const;
 
+        //! Returns the log level corresponding to a string, or nullopt if unrecognized.
+        static std::optional<BCLog::Level> GetLogLevel(std::string_view str);
         //! Returns the string representation of a log level.
         static std::string LogLevelToStr(BCLog::Level level);

And we could probably use this new constant in a few more places:

diff --git a/src/init/common.cpp b/src/init/common.cpp
--- a/src/init/common.cpp	(revision c9516e72f9c26f76aacc510e9d39448291fc2994)
+++ b/src/init/common.cpp	(revision f1467268d1159abb523fd65062d7533100a15217)
@@ -67,7 +67,7 @@
         if (level_str.find_first_of(':', 3) == std::string::npos) {
             // user passed a global log level, i.e. -loglevel=<level>
             const auto level{BCLog::Logger::GetLogLevel(level_str)};
-            if (!level || *level > BCLog::Level::Info) {
+            if (!level || *level > BCLog::UNCONDITIONAL_LOG_LEVEL) {
                 return util::Error{strprintf(_("Unsupported global logging level %s=%s. Valid values: %s."), "-loglevel", level_str, LogInstance().LogLevelsString())};
             }
             global_level = *level;
@@ -76,7 +76,7 @@
             const auto& toks = SplitString(level_str, ':');
             const auto category{toks.size() == 2 ? BCLog::Logger::GetLogCategory(toks[0]) : std::nullopt};
             const auto level{toks.size() == 2 ? BCLog::Logger::GetLogLevel(toks[1]) : std::nullopt};
-            if (!category || !level || *level > BCLog::Level::Info) {
+            if (!category || !level || *level > BCLog::UNCONDITIONAL_LOG_LEVEL) {
                 return util::Error{strprintf(_("Unsupported category-specific logging level %1$s=%2$s. Expected %1$s=<category>:<loglevel>. Valid categories: %3$s. Valid loglevels: %4$s."), "-loglevel", level_str, LogInstance().LogCategoriesString(), LogInstance().LogLevelsString())};
             }
             category_levels.emplace_back(*category, *level);
Could this naming cleanup be split before the atomic-mask change? The current code already has one threshold that means "levels at or above this always log". Giving that threshold a shared name first would make the later mask change smaller, and the startup parsing checks could use the same name instead of hardcoding `Level::Info`. ```patch diff --git a/src/logging.cpp b/src/logging.cpp index 3373063c05..e0c2b2cef2 100644 --- a/src/logging.cpp +++ b/src/logging.cpp @@ -21,7 +21,6 @@ using util::Join; using util::RemovePrefixView; const char * const DEFAULT_DEBUGLOGFILE = "debug.log"; -constexpr auto MAX_USER_SETABLE_SEVERITY_LEVEL{BCLog::Level::Info}; BCLog::Logger& LogInstance() { @@ -162,7 +161,7 @@ bool BCLog::Logger::WillLogCategoryLevel(BCLog::LogFlags category, BCLog::Level { // Log messages at Info, Warning and Error level unconditionally, so that // important troubleshooting information doesn't get lost. - if (level >= BCLog::Level::Info) return true; + if (level >= BCLog::UNCONDITIONAL_LOG_LEVEL) return true; if (!WillLogCategory(category)) return false; @@ -263,7 +262,7 @@ static std::string LogCategoryToStr(BCLog::LogFlags category) return it->second; } -static std::optional<BCLog::Level> GetLogLevel(std::string_view level_str) +std::optional<BCLog::Level> BCLog::Logger::GetLogLevel(std::string_view level_str) { if (level_str == "trace") { return BCLog::Level::Trace; @@ -586,7 +585,7 @@ bool BCLog::LogRateLimiter::Stats::Consume(uint64_t bytes) bool BCLog::Logger::SetLogLevel(std::string_view level_str) { const auto level = GetLogLevel(level_str); - if (!level.has_value() || level.value() > MAX_USER_SETABLE_SEVERITY_LEVEL) return false; + if (!level.has_value() || level.value() > BCLog::UNCONDITIONAL_LOG_LEVEL) return false; m_log_level = level.value(); return true; } @@ -597,7 +596,7 @@ bool BCLog::Logger::SetCategoryLogLevel(std::string_view category_str, std::stri if (!flag) return false; const auto level = GetLogLevel(level_str); - if (!level.has_value() || level.value() > MAX_USER_SETABLE_SEVERITY_LEVEL) return false; + if (!level.has_value() || level.value() > BCLog::UNCONDITIONAL_LOG_LEVEL) return false; STDLOCK(m_cs); m_category_log_levels[*flag] = level.value(); diff --git a/src/logging.h b/src/logging.h index 67f5d6ef00..041e341d3a 100644 --- a/src/logging.h +++ b/src/logging.h @@ -62,6 +62,8 @@ struct LogCategory { namespace BCLog { constexpr auto DEFAULT_LOG_LEVEL{Level::Debug}; + //! Log messages at this severity level and above are always emitted regardless of category settings. + constexpr auto UNCONDITIONAL_LOG_LEVEL{Level::Info}; constexpr size_t DEFAULT_MAX_LOG_BUFFER{1'000'000}; // buffer up to 1MB of log data prior to StartLogging constexpr uint64_t RATELIMIT_MAX_BYTES{1_MiB}; // maximum number of bytes per source location that can be logged within the RATELIMIT_WINDOW constexpr auto RATELIMIT_WINDOW{1h}; // time window after which log ratelimit stats are reset @@ -271,6 +273,8 @@ namespace BCLog { //! Returns a string with all user-selectable log levels. std::string LogLevelsString() const; + //! Returns the log level corresponding to a string, or nullopt if unrecognized. + static std::optional<BCLog::Level> GetLogLevel(std::string_view str); //! Returns the string representation of a log level. static std::string LogLevelToStr(BCLog::Level level); ``` And we could probably use this new constant in a few more places: ```patch diff --git a/src/init/common.cpp b/src/init/common.cpp --- a/src/init/common.cpp (revision c9516e72f9c26f76aacc510e9d39448291fc2994) +++ b/src/init/common.cpp (revision f1467268d1159abb523fd65062d7533100a15217) @@ -67,7 +67,7 @@ if (level_str.find_first_of(':', 3) == std::string::npos) { // user passed a global log level, i.e. -loglevel=<level> const auto level{BCLog::Logger::GetLogLevel(level_str)}; - if (!level || *level > BCLog::Level::Info) { + if (!level || *level > BCLog::UNCONDITIONAL_LOG_LEVEL) { return util::Error{strprintf(_("Unsupported global logging level %s=%s. Valid values: %s."), "-loglevel", level_str, LogInstance().LogLevelsString())}; } global_level = *level; @@ -76,7 +76,7 @@ const auto& toks = SplitString(level_str, ':'); const auto category{toks.size() == 2 ? BCLog::Logger::GetLogCategory(toks[0]) : std::nullopt}; const auto level{toks.size() == 2 ? BCLog::Logger::GetLogLevel(toks[1]) : std::nullopt}; - if (!category || !level || *level > BCLog::Level::Info) { + if (!category || !level || *level > BCLog::UNCONDITIONAL_LOG_LEVEL) { return util::Error{strprintf(_("Unsupported category-specific logging level %1$s=%2$s. Expected %1$s=<category>:<loglevel>. Valid categories: %3$s. Valid loglevels: %4$s."), "-loglevel", level_str, LogInstance().LogCategoriesString(), LogInstance().LogLevelsString())}; } category_levels.emplace_back(*category, *level); ```
l0rinc (Migrated from github.com) commented 2026-05-22 11:26:59 +00:00

Could the comment say explicitly that m_levels only stores conditional levels (Trace and Debug), while Info and above bypass this array?
I initially read the threshold wording as trying to represent all severities, but the array deliberately stops at UNCONDITIONAL_LOG_LEVEL.

Seems we have two fundamentally different ways of logging that we're forcing together here. Do you anticipate category-based filtering for all levels in the future?

I find this design confusing for multiple reasons:

  • Should we guard against setting log levels for unconditional logs, either through the API or internal checks? My understanding is that we're setting dummy values there and just ignoring them later.
  • debug/trace can also be turned on by BCLog::ALL, and they would take a different route than unconditional info/warn/error.
Could the comment say explicitly that `m_levels` only stores conditional levels (`Trace` and `Debug`), while `Info` and above bypass this array? I initially read the threshold wording as trying to represent all severities, but the array deliberately stops at `UNCONDITIONAL_LOG_LEVEL`. Seems we have two fundamentally different ways of logging that we're forcing together here. Do you anticipate category-based filtering for all levels in the future? I find this design confusing for multiple reasons: * Should we guard against setting log levels for unconditional logs, either through the API or internal checks? My understanding is that we're setting dummy values there and just ignoring them later. * `debug`/`trace` can also be turned on by `BCLog::ALL`, and they would take a different route than unconditional `info`/`warn`/`error`.
l0rinc (Migrated from github.com) commented 2026-05-22 14:20:08 +00:00

Could we add a test that goes through this runtime-enable path after startup configured the category at Trace?

The PR description notes that runtime enables now use Debug even if startup used Trace. A test through the RPC/kernel entry point would make that intentional behavior change easy to verify.

Could we add a test that goes through this runtime-enable path after startup configured the category at Trace? The PR description notes that runtime enables now use Debug even if startup used Trace. A test through the RPC/kernel entry point would make that intentional behavior change easy to verify.
Lines 256-257
l0rinc (Migrated from github.com) commented 2026-05-22 14:30:13 +00:00

We can probably deduplicate this:

    bool is_libevent_enabled{LogInstance().WillLogCategoryLevel(BCLog::LIBEVENT, BCLog::Level::Debug)};
    if (original_libevent != is_libevent_enabled) UpdateHTTPServerLogging(is_libevent_enabled);
We can probably deduplicate this: ```suggestion bool is_libevent_enabled{LogInstance().WillLogCategoryLevel(BCLog::LIBEVENT, BCLog::Level::Debug)}; if (original_libevent != is_libevent_enabled) UpdateHTTPServerLogging(is_libevent_enabled); ```
l0rinc (Migrated from github.com) commented 2026-05-21 08:21:42 +00:00

This string-parsing overload no longer has production callers after startup parsing moves out of Logger. Could we drop it and have the test use the typed setter directly?

diff --git a/src/logging.cpp b/src/logging.cpp
index 7c1777adc1..a0fae9badf 100644
--- a/src/logging.cpp
+++ b/src/logging.cpp
@@ -567,18 +567,6 @@ bool BCLog::LogRateLimiter::Stats::Consume(uint64_t bytes)
     return true;
 }
 
-bool BCLog::Logger::SetCategoryLogLevel(std::string_view category_str, std::string_view level_str)
-{
-    const auto flag{GetLogCategory(category_str)};
-    if (!flag) return false;
-
-    const auto level = GetLogLevel(level_str);
-    if (!level.has_value() || level.value() > BCLog::UNCONDITIONAL_LOG_LEVEL) return false;
-
-    SetCategoryLogLevel(*flag, level.value());
-    return true;
-}
-
 bool util::log::ShouldLog(Category category, Level level)
 {
     return LogInstance().WillLogCategoryLevel(static_cast<BCLog::LogFlags>(category), level);
diff --git a/src/logging.h b/src/logging.h
index b44349cc55..a543562a1e 100644
--- a/src/logging.h
+++ b/src/logging.h
@@ -230,7 +230,6 @@ namespace BCLog {
         //! Set the log level threshold for a specific category (or ALL categories if
         //! flag == BCLog::ALL). Levels >= UNCONDITIONAL_LOG_LEVEL disable the category.
         void SetCategoryLogLevel(CategoryMask category, Level level);
-        bool SetCategoryLogLevel(std::string_view category_str, std::string_view level_str);
 
         //! Returns true if a message at the given category and level would be logged.
         bool WillLogCategoryLevel(LogFlags category, Level level) const;
diff --git a/src/test/logging_tests.cpp b/src/test/logging_tests.cpp
index 15e3b8ee4b..413df24af0 100644
--- a/src/test/logging_tests.cpp
+++ b/src/test/logging_tests.cpp
@@ -175,7 +175,7 @@ BOOST_FIXTURE_TEST_CASE(logging_LogPrintMacros_CategoryName, LogSetup)
 BOOST_FIXTURE_TEST_CASE(logging_SeverityLevels, LogSetup)
 {
     LogInstance().SetCategoryLogLevel(BCLog::LogFlags::ALL, BCLog::Level::Debug);
-    LogInstance().SetCategoryLogLevel(/*category_str=*/"net", /*level_str=*/"info");
+    LogInstance().SetCategoryLogLevel(BCLog::NET, BCLog::Level::Info);
 
     // All categories at Debug level
     LogInfo("info_%s", 1);
This string-parsing overload no longer has production callers after startup parsing moves out of Logger. Could we drop it and have the test use the typed setter directly? ```patch diff --git a/src/logging.cpp b/src/logging.cpp index 7c1777adc1..a0fae9badf 100644 --- a/src/logging.cpp +++ b/src/logging.cpp @@ -567,18 +567,6 @@ bool BCLog::LogRateLimiter::Stats::Consume(uint64_t bytes) return true; } -bool BCLog::Logger::SetCategoryLogLevel(std::string_view category_str, std::string_view level_str) -{ - const auto flag{GetLogCategory(category_str)}; - if (!flag) return false; - - const auto level = GetLogLevel(level_str); - if (!level.has_value() || level.value() > BCLog::UNCONDITIONAL_LOG_LEVEL) return false; - - SetCategoryLogLevel(*flag, level.value()); - return true; -} - bool util::log::ShouldLog(Category category, Level level) { return LogInstance().WillLogCategoryLevel(static_cast<BCLog::LogFlags>(category), level); diff --git a/src/logging.h b/src/logging.h index b44349cc55..a543562a1e 100644 --- a/src/logging.h +++ b/src/logging.h @@ -230,7 +230,6 @@ namespace BCLog { //! Set the log level threshold for a specific category (or ALL categories if //! flag == BCLog::ALL). Levels >= UNCONDITIONAL_LOG_LEVEL disable the category. void SetCategoryLogLevel(CategoryMask category, Level level); - bool SetCategoryLogLevel(std::string_view category_str, std::string_view level_str); //! Returns true if a message at the given category and level would be logged. bool WillLogCategoryLevel(LogFlags category, Level level) const; diff --git a/src/test/logging_tests.cpp b/src/test/logging_tests.cpp index 15e3b8ee4b..413df24af0 100644 --- a/src/test/logging_tests.cpp +++ b/src/test/logging_tests.cpp @@ -175,7 +175,7 @@ BOOST_FIXTURE_TEST_CASE(logging_LogPrintMacros_CategoryName, LogSetup) BOOST_FIXTURE_TEST_CASE(logging_SeverityLevels, LogSetup) { LogInstance().SetCategoryLogLevel(BCLog::LogFlags::ALL, BCLog::Level::Debug); - LogInstance().SetCategoryLogLevel(/*category_str=*/"net", /*level_str=*/"info"); + LogInstance().SetCategoryLogLevel(BCLog::NET, BCLog::Level::Info); // All categories at Debug level LogInfo("info_%s", 1); ```
l0rinc (Migrated from github.com) commented 2026-05-21 08:10:13 +00:00

I think it should be possible to split the PR up and I'll experiment with this.

I would prefer peeling off each method separately to have some progress during review.
For example, getLogCategories() is only used in a single place to decide whether the GUI should show debug information, and that can be split out before the category-mask refactor.

Reviewing whether the GUI should check for any enabled category mask or for actual Debug-level logging is already non-trivial and worthy of separation.

isAnyDebugLoggingEnabled
diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp
index ac73158768..969ecb3910 100644
--- a/src/bitcoind.cpp
+++ b/src/bitcoind.cpp
@@ -14,6 +14,7 @@
 #include <compat/compat.h>
 #include <init.h>
 #include <interfaces/chain.h>
+#include <logging.h>
 #include <interfaces/init.h>
 #include <kernel/context.h>
 #include <node/context.h>
diff --git a/src/interfaces/node.h b/src/interfaces/node.h
index f6d8209f07..294b71e0eb 100644
--- a/src/interfaces/node.h
+++ b/src/interfaces/node.h
@@ -7,7 +7,6 @@
 
 #include <common/settings.h>
 #include <consensus/amount.h>
-#include <logging.h>
 #include <net.h>
 #include <net_types.h>
 #include <netaddress.h>
@@ -84,8 +83,8 @@ public:
     //! Get exit status.
     virtual int getExitStatus() = 0;
 
-    // Get log flags.
-    virtual BCLog::CategoryMask getLogCategories() = 0;
+    //! Returns true if any debug logging categories are enabled.
+    virtual bool isAnyDebugLoggingEnabled() = 0;
 
     //! Initialize app dependencies.
     virtual bool baseInitialize() = 0;
diff --git a/src/node/interfaces.cpp b/src/node/interfaces.cpp
index 16db8692a1..347a998faf 100644
--- a/src/node/interfaces.cpp
+++ b/src/node/interfaces.cpp
@@ -112,7 +112,7 @@ public:
     void initParameterInteraction() override { InitParameterInteraction(args()); }
     bilingual_str getWarnings() override { return Join(Assert(m_context->warnings)->GetMessages(), Untranslated("<hr />")); }
     int getExitStatus() override { return Assert(m_context)->exit_status.load(); }
-    BCLog::CategoryMask getLogCategories() override { return LogInstance().GetCategoryMask(); }
+    bool isAnyDebugLoggingEnabled() override { return LogInstance().WillLogCategoryLevel(BCLog::ALL, BCLog::Level::Debug); }
     bool baseInitialize() override
     {
         if (!AppInitBasicSetup(args(), Assert(context())->exit_status)) return false;
diff --git a/src/qt/transactiondesc.cpp b/src/qt/transactiondesc.cpp
index d9c97d8529..3e59b01c49 100644
--- a/src/qt/transactiondesc.cpp
+++ b/src/qt/transactiondesc.cpp
@@ -314,7 +314,7 @@ QString TransactionDesc::toHTML(interfaces::Node& node, interfaces::Wallet& wall
     //
     // Debug view
     //
-    if (node.getLogCategories() != BCLog::NONE)
+    if (node.isAnyDebugLoggingEnabled())
     {
         strHTML += "<hr><br>" + tr("Debug information") + "<br><br>";
         for (const CTxIn& txin : wtx.tx->vin)
diff --git a/src/test/node_init_tests.cpp b/src/test/node_init_tests.cpp
index 44635dd4aa..fb9bce6cff 100644
--- a/src/test/node_init_tests.cpp
+++ b/src/test/node_init_tests.cpp
@@ -4,6 +4,7 @@
 
 #include <init.h>
 #include <interfaces/init.h>
+#include <logging.h>
 #include <rpc/server.h>
 
 #include <boost/test/unit_test.hpp>
> I think it should be possible to split the PR up and I'll experiment with this. I would prefer peeling off each method separately to have some progress during review. For example, `getLogCategories()` is only used in a single place to decide whether the GUI should show debug information, and that can be split out before the category-mask refactor. Reviewing whether the GUI should check for any enabled category mask or for actual Debug-level logging is already non-trivial and worthy of separation. <details><summary>isAnyDebugLoggingEnabled</summary> ```patch diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index ac73158768..969ecb3910 100644 --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -14,6 +14,7 @@ #include <compat/compat.h> #include <init.h> #include <interfaces/chain.h> +#include <logging.h> #include <interfaces/init.h> #include <kernel/context.h> #include <node/context.h> diff --git a/src/interfaces/node.h b/src/interfaces/node.h index f6d8209f07..294b71e0eb 100644 --- a/src/interfaces/node.h +++ b/src/interfaces/node.h @@ -7,7 +7,6 @@ #include <common/settings.h> #include <consensus/amount.h> -#include <logging.h> #include <net.h> #include <net_types.h> #include <netaddress.h> @@ -84,8 +83,8 @@ public: //! Get exit status. virtual int getExitStatus() = 0; - // Get log flags. - virtual BCLog::CategoryMask getLogCategories() = 0; + //! Returns true if any debug logging categories are enabled. + virtual bool isAnyDebugLoggingEnabled() = 0; //! Initialize app dependencies. virtual bool baseInitialize() = 0; diff --git a/src/node/interfaces.cpp b/src/node/interfaces.cpp index 16db8692a1..347a998faf 100644 --- a/src/node/interfaces.cpp +++ b/src/node/interfaces.cpp @@ -112,7 +112,7 @@ public: void initParameterInteraction() override { InitParameterInteraction(args()); } bilingual_str getWarnings() override { return Join(Assert(m_context->warnings)->GetMessages(), Untranslated("<hr />")); } int getExitStatus() override { return Assert(m_context)->exit_status.load(); } - BCLog::CategoryMask getLogCategories() override { return LogInstance().GetCategoryMask(); } + bool isAnyDebugLoggingEnabled() override { return LogInstance().WillLogCategoryLevel(BCLog::ALL, BCLog::Level::Debug); } bool baseInitialize() override { if (!AppInitBasicSetup(args(), Assert(context())->exit_status)) return false; diff --git a/src/qt/transactiondesc.cpp b/src/qt/transactiondesc.cpp index d9c97d8529..3e59b01c49 100644 --- a/src/qt/transactiondesc.cpp +++ b/src/qt/transactiondesc.cpp @@ -314,7 +314,7 @@ QString TransactionDesc::toHTML(interfaces::Node& node, interfaces::Wallet& wall // // Debug view // - if (node.getLogCategories() != BCLog::NONE) + if (node.isAnyDebugLoggingEnabled()) { strHTML += "<hr><br>" + tr("Debug information") + "<br><br>"; for (const CTxIn& txin : wtx.tx->vin) diff --git a/src/test/node_init_tests.cpp b/src/test/node_init_tests.cpp index 44635dd4aa..fb9bce6cff 100644 --- a/src/test/node_init_tests.cpp +++ b/src/test/node_init_tests.cpp @@ -4,6 +4,7 @@ #include <init.h> #include <interfaces/init.h> +#include <logging.h> #include <rpc/server.h> #include <boost/test/unit_test.hpp> ``` </details>
l0rinc (Migrated from github.com) commented 2026-05-21 12:55:21 +00:00

Isn’t this a behavior change?

Previously, setting a category level at startup stored the override, but it had no visible effect unless the category was also enabled with -debug.
Here, setting -loglevel=net:trace appears to enable net by itself.

Isn’t this a behavior change? Previously, setting a category level at startup stored the override, but it had no visible effect unless the category was also enabled with -debug. Here, setting `-loglevel=net:trace` appears to enable net by itself.
ryanofsky commented 2026-05-26 20:20:26 +00:00 (Migrated from github.com)

Rebased ccd90a75125586f4f5a03fda5477738b10745d20 -> a76b13796a59e0c91548882c1a1970943a200153 (pr/levels.1 -> pr/levels.2, compare) due to conflict with #34806

<!-- begin push-2 --> Rebased ccd90a75125586f4f5a03fda5477738b10745d20 -> a76b13796a59e0c91548882c1a1970943a200153 ([`pr/levels.1`](https://github.com/ryanofsky/bitcoin/commits/pr/levels.1) -> [`pr/levels.2`](https://github.com/ryanofsky/bitcoin/commits/pr/levels.2), [compare](https://github.com/ryanofsky/bitcoin/compare/pr/levels.1-rebase..pr/levels.2))<!-- end --> due to conflict with #34806
DrahtBot commented 2026-05-26 21:47:02 +00:00 (Migrated from github.com)

🚧 At least one of the CI tasks failed.
Task Windows-cross to x86_64, msvcrt: https://github.com/bitcoin/bitcoin/actions/runs/26472785758/job/77960548589
LLM reason (✨ experimental): CI failed due to a C++ build error in src/init/common.cpp: GetLogCategory is not declared (missing/renamed logging helper).

Hints

Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:

  • Possibly due to a silent merge conflict (the changes in this pull request being
    incompatible with the current code in the target branch). If so, make sure to rebase on the latest
    commit of the target branch.

  • A sanitizer issue, which can only be found by compiling with the sanitizer and running the
    affected test.

  • An intermittent issue.

Leave a comment here, if you need help tracking down a confusing failure.

<!--85328a0da195eb286784d51f73fa0af9--> 🚧 At least one of the CI tasks failed. <sub>Task `Windows-cross to x86_64, msvcrt`: https://github.com/bitcoin/bitcoin/actions/runs/26472785758/job/77960548589</sub> <sub>LLM reason (✨ experimental): CI failed due to a C++ build error in `src/init/common.cpp`: `GetLogCategory` is not declared (missing/renamed logging helper).</sub> <details><summary>Hints</summary> Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example: * Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch. * A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test. * An intermittent issue. Leave a comment here, if you need help tracking down a confusing failure. </details>
ryanofsky (Migrated from github.com) reviewed 2026-05-27 17:39:33 +00:00
ryanofsky (Migrated from github.com) left a comment

Thanks for the review! PR is now split up instead of being a single commit and I implemented most suggestions, but need to follow up on the ideas for adding more tests. (EDIT: tests are added now)

Updated a76b13796a59e0c91548882c1a1970943a200153 -> 30cb9ee48027f4b32ca1c98e2cafc1a6e4388e53 (pr/levels.2 -> pr/levels.3, compare) with review suggestions

Updated 30cb9ee48027f4b32ca1c98e2cafc1a6e4388e53 -> dd4b33e01ca2441fcb875e0ecb084643ecc50cd8 (pr/levels.3 -> pr/levels.4, compare) adding new tests commits before changes to cover more behaviors, also making other small cleanups

Updated dd4b33e01ca2441fcb875e0ecb084643ecc50cd8 -> 70b4bee3cc7392a8189a98d35f382e210ae7c2cc (pr/levels.4 -> pr/levels.5, compare) to fix CI link errors: LogInstance() hidden by REDUCE_EXPORTS=ON; override visibility for logging.cpp in kernel build https://github.com/bitcoin/bitcoin/actions/runs/26643504769/job/78546254795

Updated 70b4bee3cc7392a8189a98d35f382e210ae7c2cc -> be5e736f4976686c3fa0200f35e10ce0b656c351 (pr/levels.5 -> pr/levels.6, compare) to fix Windows DLL link errors in test_kernel https://github.com/bitcoin/bitcoin/actions/runs/26787798064/job/78967518054

Updated be5e736f4976686c3fa0200f35e10ce0b656c351 -> 395473b97ad229d4c80c45bd5dcfa4c885acf09d (pr/levels.6 -> pr/levels.7, compare) to fix Windows cross CI: --export-dynamic-symbol and -fvisibility=default are ELF-only; use .def file to export logging symbols from DLL https://github.com/bitcoin/bitcoin/actions/runs/27141219495/job/80118211985

Thanks for the review! PR is now split up instead of being a single commit and I implemented most suggestions, but need to follow up on the ideas for adding more tests. (EDIT: tests are added now) <!-- begin push-3 --> Updated a76b13796a59e0c91548882c1a1970943a200153 -> 30cb9ee48027f4b32ca1c98e2cafc1a6e4388e53 ([`pr/levels.2`](https://github.com/ryanofsky/bitcoin/commits/pr/levels.2) -> [`pr/levels.3`](https://github.com/ryanofsky/bitcoin/commits/pr/levels.3), [compare](https://github.com/ryanofsky/bitcoin/compare/pr/levels.2..pr/levels.3))<!-- end --> with review suggestions <!-- begin push-4 --> Updated 30cb9ee48027f4b32ca1c98e2cafc1a6e4388e53 -> dd4b33e01ca2441fcb875e0ecb084643ecc50cd8 ([`pr/levels.3`](https://github.com/ryanofsky/bitcoin/commits/pr/levels.3) -> [`pr/levels.4`](https://github.com/ryanofsky/bitcoin/commits/pr/levels.4), [compare](https://github.com/ryanofsky/bitcoin/compare/pr/levels.3..pr/levels.4))<!-- end --> adding new tests commits before changes to cover more behaviors, also making other small cleanups <!-- begin push-5 --> Updated dd4b33e01ca2441fcb875e0ecb084643ecc50cd8 -> 70b4bee3cc7392a8189a98d35f382e210ae7c2cc ([`pr/levels.4`](https://github.com/ryanofsky/bitcoin/commits/pr/levels.4) -> [`pr/levels.5`](https://github.com/ryanofsky/bitcoin/commits/pr/levels.5), [compare](https://github.com/ryanofsky/bitcoin/compare/pr/levels.4..pr/levels.5))<!-- end --> to fix CI link errors: LogInstance() hidden by REDUCE_EXPORTS=ON; override visibility for logging.cpp in kernel build https://github.com/bitcoin/bitcoin/actions/runs/26643504769/job/78546254795<!-- end --> <!-- begin push-6 --> Updated 70b4bee3cc7392a8189a98d35f382e210ae7c2cc -> be5e736f4976686c3fa0200f35e10ce0b656c351 ([`pr/levels.5`](https://github.com/ryanofsky/bitcoin/commits/pr/levels.5) -> [`pr/levels.6`](https://github.com/ryanofsky/bitcoin/commits/pr/levels.6), [compare](https://github.com/ryanofsky/bitcoin/compare/pr/levels.5..pr/levels.6)) to fix Windows DLL link errors in test_kernel https://github.com/bitcoin/bitcoin/actions/runs/26787798064/job/78967518054<!-- end --> <!-- begin push-7 --> Updated be5e736f4976686c3fa0200f35e10ce0b656c351 -> 395473b97ad229d4c80c45bd5dcfa4c885acf09d ([`pr/levels.6`](https://github.com/ryanofsky/bitcoin/commits/pr/levels.6) -> [`pr/levels.7`](https://github.com/ryanofsky/bitcoin/commits/pr/levels.7), [compare](https://github.com/ryanofsky/bitcoin/compare/pr/levels.6..pr/levels.7))<!-- end --> to fix Windows cross CI: --export-dynamic-symbol and -fvisibility=default are ELF-only; use .def file to export logging symbols from DLL https://github.com/bitcoin/bitcoin/actions/runs/27141219495/job/80118211985<!-- end -->
ryanofsky (Migrated from github.com) commented 2026-05-27 17:16:55 +00:00

re: https://github.com/bitcoin/bitcoin/pull/35322#discussion_r3289129041

This looks similar to the earlier concern. Isn't this a behavior change as well?

Yes this analogous to the other change you pointed out https://github.com/bitcoin/bitcoin/pull/35322#discussion_r3281289661.

In this case I think the new behavior is probably better as there is no point to kernel code setting a level for a category that is ignored because the category is enabled. (For bitcoind it might have made sense previously because logging RPC is more limited than the kernel API.)

But this behavior change should be documented and tested, so I will try to add your test suggestion and follow up.

re: https://github.com/bitcoin/bitcoin/pull/35322#discussion_r3289129041 > This looks similar to the earlier concern. Isn't this a behavior change as well? Yes this analogous to the other change you pointed out https://github.com/bitcoin/bitcoin/pull/35322#discussion_r3281289661. In this case I think the new behavior is probably better as there is no point to kernel code setting a level for a category that is ignored because the category is enabled. (For `bitcoind` it might have made sense previously because `logging` RPC is more limited than the kernel API.) But this behavior change should be documented and tested, so I will try to add your test suggestion and follow up.
ryanofsky (Migrated from github.com) commented 2026-05-27 17:05:25 +00:00

re: https://github.com/bitcoin/bitcoin/pull/35322#discussion_r3288806782

This loop has dual behavior that needed extra explanation in the header. Maybe we could make it more obvious via code instead

I added a comment here to be clearer, and I'm open to feedback on different ways to write this, but I feel like the current version is actually simpler than the suggestions (of using two for loops or hardcoding severity constants). The current code just loops through each level and setting category bits to 1 if the level is enabled, 0 if disabled.

re: https://github.com/bitcoin/bitcoin/pull/35322#discussion_r3288806782 > This loop has dual behavior that needed extra explanation in the header. Maybe we could make it more obvious via code instead I added a comment here to be clearer, and I'm open to feedback on different ways to write this, but I feel like the current version is actually simpler than the suggestions (of using two `for` loops or hardcoding severity constants). The current code just loops through each level and setting category bits to 1 if the level is enabled, 0 if disabled.
Lines 143-145
ryanofsky (Migrated from github.com) commented 2026-05-27 16:58:27 +00:00

re: https://github.com/bitcoin/bitcoin/pull/35322#discussion_r3288138282

This seems like a code smell (even though it was similar before)

Yeah agree this could be better, should be improved now but let me know.

re: https://github.com/bitcoin/bitcoin/pull/35322#discussion_r3288138282 > This seems like a code smell (even though it was similar before) Yeah agree this could be better, should be improved now but let me know.
ryanofsky (Migrated from github.com) commented 2026-05-27 16:23:55 +00:00

re: https://github.com/bitcoin/bitcoin/pull/35322#discussion_r3280651475

This looks like save/restore plumbing for tests, not part of the core representation swap. Could it be split into the commit where the test fixtures first need to snapshot the level masks?

Yes, this should be done now.

re: https://github.com/bitcoin/bitcoin/pull/35322#discussion_r3280651475 > This looks like save/restore plumbing for tests, not part of the core representation swap. Could it be split into the commit where the test fixtures first need to snapshot the level masks? Yes, this should be done now.
ryanofsky (Migrated from github.com) commented 2026-05-27 16:23:08 +00:00

re: https://github.com/bitcoin/bitcoin/pull/35322#discussion_r3279807731

Could this naming cleanup be split before the atomic-mask change?

Following your other suggestion https://github.com/bitcoin/bitcoin/pull/35322#discussion_r3279693120 this -loglevel parsing code is now dropped from the logger class.

the startup parsing checks could use the same name instead of hardcoding Level::Info.

This is probably worth improving still. I'm happy to follow any preferences expressed in this PR or #35387 which improves the -loglevel implementation specifically. For now the code is using Info just to be explicit about the behavior it is trying to preserve.

re: https://github.com/bitcoin/bitcoin/pull/35322#discussion_r3279807731 > Could this naming cleanup be split before the atomic-mask change? Following your other suggestion https://github.com/bitcoin/bitcoin/pull/35322#discussion_r3279693120 this -loglevel parsing code is now dropped from the logger class. > the startup parsing checks could use the same name instead of hardcoding `Level::Info`. This is probably worth improving still. I'm happy to follow any preferences expressed in this PR or #35387 which improves the `-loglevel` implementation specifically. For now the code is using Info just to be explicit about the behavior it is trying to preserve.
ryanofsky (Migrated from github.com) commented 2026-05-27 16:48:14 +00:00

re: https://github.com/bitcoin/bitcoin/pull/35322#discussion_r3288013785

Could the comment say explicitly that m_levels only stores conditional levels (Trace and Debug), while Info and above bypass this array?

Yes, changed array declaration and added comment to make this clearer.

Seems we have two fundamentally different ways of logging that we're forcing together here.

I don't think that's right. Logger accepts a category and severity level for each log message and it provides a SetCategoryLogLevel(category, level) method to set a minimum severity level for each category and control what is logged.

The fact that Logger always logs the highest severity messages seems like an internal implementation detail, not a reason to complicate its API. Or if the API should be more complicated, it would be good to know why, or what the goal would be.

Do you anticipate category-based filtering for all levels in the future?

No, I think it makes sense to have some levels that can't be turned off or filtered by category. (IMO it would best if to introduce a new critical level for this purpose, so lower-severity errors, warnings, and status messages could be distinguished from each other. But this is just a weak preference and should be unrelated to this PR.)

Should we guard against setting log levels for unconditional logs, either through the API or internal checks?

I don't think I have an opinion about this. Having something like separate enums for conditional and unconditional levels could be reasonable, but I'd want to know what the goal would be, or what types of bugs this could prevent.

  • debug/trace can also be turned on by BCLog::ALL, and they would take a different route than unconditional info/warn/error.

I'm not sure I understand the concern. Inside the Logger class, all messages are taking the same route. It is intentional to provide a way to turn on debug and tracing for all categories. The decision to make it difficult to turn off info/warning/error logs doesn't seem like it should affect this.

re: https://github.com/bitcoin/bitcoin/pull/35322#discussion_r3288013785 > Could the comment say explicitly that `m_levels` only stores conditional levels (`Trace` and `Debug`), while `Info` and above bypass this array? Yes, changed array declaration and added comment to make this clearer. > Seems we have two fundamentally different ways of logging that we're forcing together here. I don't think that's right. `Logger` accepts a category and severity level for each log message and it provides a `SetCategoryLogLevel(category, level)` method to set a minimum severity level for each category and control what is logged. The fact that `Logger` always logs the highest severity messages seems like an internal implementation detail, not a reason to complicate its API. Or if the API should be more complicated, it would be good to know why, or what the goal would be. > Do you anticipate category-based filtering for all levels in the future? No, I think it makes sense to have some levels that can't be turned off or filtered by category. (IMO it would best if to introduce a new critical level for this purpose, so lower-severity errors, warnings, and status messages could be distinguished from each other. But this is just a weak preference and should be unrelated to this PR.) > Should we guard against setting log levels for unconditional logs, either through the API or internal checks? I don't think I have an opinion about this. Having something like separate enums for conditional and unconditional levels could be reasonable, but I'd want to know what the goal would be, or what types of bugs this could prevent. > * `debug`/`trace` can also be turned on by `BCLog::ALL`, and they would take a different route than unconditional `info`/`warn`/`error`. I'm not sure I understand the concern. Inside the `Logger` class, all messages are taking the same route. It is intentional to provide a way to turn on debug and tracing for all categories. The decision to make it difficult to turn off info/warning/error logs doesn't seem like it should affect this.
ryanofsky (Migrated from github.com) commented 2026-05-27 17:07:39 +00:00

re: https://github.com/bitcoin/bitcoin/pull/35322#discussion_r3289031399

Could we add a test that goes through this runtime-enable path after startup configured the category at Trace?

The PR description notes that runtime enables now use Debug even if startup used Trace. A test through the RPC/kernel entry point would make that intentional behavior change easy to verify.

Yes this is a good idea. Current PR doesn't add new tests but it should and I will follow up with this.

re: https://github.com/bitcoin/bitcoin/pull/35322#discussion_r3289031399 > Could we add a test that goes through this runtime-enable path after startup configured the category at Trace? > > The PR description notes that runtime enables now use Debug even if startup used Trace. A test through the RPC/kernel entry point would make that intentional behavior change easy to verify. Yes this is a good idea. Current PR doesn't add new tests but it should and I will follow up with this.
Lines 256-257
ryanofsky (Migrated from github.com) commented 2026-05-27 17:07:59 +00:00
re: https://github.com/bitcoin/bitcoin/pull/35322#discussion_r3289092797 > We can probably deduplicate this: Make sense, appied suggestion
ryanofsky (Migrated from github.com) commented 2026-05-27 16:15:45 +00:00

re: https://github.com/bitcoin/bitcoin/pull/35322#discussion_r3279693120

This string-parsing overload no longer has production callers after startup parsing moves out of Logger. Could we drop it and have the test use the typed setter directly?

Nice find! This lets another logger method to be dropped. Implemented this change.

re: https://github.com/bitcoin/bitcoin/pull/35322#discussion_r3279693120 > This string-parsing overload no longer has production callers after startup parsing moves out of Logger. Could we drop it and have the test use the typed setter directly? Nice find! This lets another logger method to be dropped. Implemented this change.
ryanofsky (Migrated from github.com) commented 2026-05-27 16:14:08 +00:00

re: https://github.com/bitcoin/bitcoin/pull/35322#discussion_r3279624744

I would prefer peeling off each method separately to have some progress during review.

Makes sense, and latest push removes each method in separate commits. Splitting this up does add some churn to the PR, because there is now temporary code added in the first commit that is removed in later commits. So some reviewers may prefer to just look at the overall diff, but probably splitting is an improvement.

re: https://github.com/bitcoin/bitcoin/pull/35322#discussion_r3279624744 > I would prefer peeling off each method separately to have some progress during review. Makes sense, and latest push removes each method in separate commits. Splitting this up does add some churn to the PR, because there is now temporary code added in the first commit that is removed in later commits. So some reviewers may prefer to just look at the overall diff, but probably splitting is an improvement.
ryanofsky (Migrated from github.com) commented 2026-05-27 16:27:46 +00:00

re: https://github.com/bitcoin/bitcoin/pull/35322#discussion_r3281289661

Isn’t this a behavior change?

Yes, nice catch! I do think this behavior change is good, but it wasn't intended to be part of this PR. It's fixed by making -loglevel only update the levels of previously enabled categories.

Edit: To follow up, I should add a test to make sure a standalone -loglevel option without -debug continues to be ignored.

re: https://github.com/bitcoin/bitcoin/pull/35322#discussion_r3281289661 > Isn’t this a behavior change? Yes, nice catch! I do think this behavior change is good, but it wasn't intended to be part of this PR. It's fixed by making `-loglevel` only update the levels of previously enabled categories. Edit: To follow up, I should add a test to make sure a standalone `-loglevel` option without `-debug` continues to be ignored.
DrahtBot commented 2026-05-29 18:10:54 +00:00 (Migrated from github.com)

🚧 At least one of the CI tasks failed.
Task Windows-cross to x86_64, ucrt: https://github.com/bitcoin/bitcoin/actions/runs/26643504769/job/78546254615
LLM reason (✨ experimental): Link step for test_kernel.exe failed with undefined references to LogInstance() / BCLog::Logger::WillLogCategoryLevel().

Hints

Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:

  • Possibly due to a silent merge conflict (the changes in this pull request being
    incompatible with the current code in the target branch). If so, make sure to rebase on the latest
    commit of the target branch.

  • A sanitizer issue, which can only be found by compiling with the sanitizer and running the
    affected test.

  • An intermittent issue.

Leave a comment here, if you need help tracking down a confusing failure.

<!--85328a0da195eb286784d51f73fa0af9--> 🚧 At least one of the CI tasks failed. <sub>Task `Windows-cross to x86_64, ucrt`: https://github.com/bitcoin/bitcoin/actions/runs/26643504769/job/78546254615</sub> <sub>LLM reason (✨ experimental): Link step for `test_kernel.exe` failed with undefined references to `LogInstance()` / `BCLog::Logger::WillLogCategoryLevel()`.</sub> <details><summary>Hints</summary> Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example: * Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch. * A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test. * An intermittent issue. Leave a comment here, if you need help tracking down a confusing failure. </details>
DrahtBot commented 2026-06-22 14:11:44 +00:00 (Migrated from github.com)

🐙 This pull request conflicts with the target branch and needs rebase.

<!--cf906140f33d8803c4a75a2196329ecb--> 🐙 This pull request conflicts with the target branch and [needs rebase](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#rebasing-changes).
DrahtBot commented 2026-06-24 17:01:52 +00:00 (Migrated from github.com)

🚧 At least one of the CI tasks failed.
Task test ancestor commits: https://github.com/bitcoin/bitcoin/actions/runs/28106965454/job/83223705517
LLM reason (✨ experimental): CI failed because the logging_tests ctest suite had 1 failing test (254 - logging_tests (Failed)), causing ctest to exit with non-zero status.

Hints

Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:

  • Possibly due to a silent merge conflict (the changes in this pull request being
    incompatible with the current code in the target branch). If so, make sure to rebase on the latest
    commit of the target branch.

  • A sanitizer issue, which can only be found by compiling with the sanitizer and running the
    affected test.

  • An intermittent issue.

Leave a comment here, if you need help tracking down a confusing failure.

<!--85328a0da195eb286784d51f73fa0af9--> 🚧 At least one of the CI tasks failed. <sub>Task `test ancestor commits`: https://github.com/bitcoin/bitcoin/actions/runs/28106965454/job/83223705517</sub> <sub>LLM reason (✨ experimental): CI failed because the `logging_tests` ctest suite had 1 failing test (`254 - logging_tests (Failed)`), causing `ctest` to exit with non-zero status.</sub> <details><summary>Hints</summary> Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example: * Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch. * A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test. * An intermittent issue. Leave a comment here, if you need help tracking down a confusing failure. </details>
DrahtBot commented 2026-06-30 17:25:05 +00:00 (Migrated from github.com)

🐙 This pull request conflicts with the target branch and needs rebase.

<!--cf906140f33d8803c4a75a2196329ecb--> 🐙 This pull request conflicts with the target branch and [needs rebase](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#rebasing-changes).
DrahtBot commented 2026-08-04 20:34:56 +00:00 (Migrated from github.com)

🐙 This pull request conflicts with the target branch and needs rebase.

<!--cf906140f33d8803c4a75a2196329ecb--> 🐙 This pull request conflicts with the target branch and [needs rebase](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#rebasing-changes).
DrahtBot commented 2026-09-29 16:30:30 +00:00 (Migrated from github.com)

🐙 This pull request conflicts with the target branch and needs rebase.

<!--cf906140f33d8803c4a75a2196329ecb--> 🐙 This pull request conflicts with the target branch and [needs rebase](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#rebasing-changes).
First-time contributor

🟠 Minor · -loglevel results depend on option order

Mixing global and per-category -loglevel values can silently lose or add debug/trace output, depending on option order.

Location: src/init/common.cpp:73 (head).

🔵 Suggestion · Including an active category lowers its threshold from trace to debug

Including an already-active category now drops its trace output, although the release note describes only re-enabling categories.

Location: src/rpc/node.cpp:225 (head).

🔵 Suggestion · An info threshold changes category status and startup defaults

With -debug=<cat> -loglevel=info, category status, debug-log shrinking, and GUI details change at startup, despite unchanged log output.

Location: src/init/common.cpp:129 (head).

🔵 Suggestion · logging.h uses std::unordered_map without including its header

LogRateLimiter still declares an std::unordered_map member, so logging.h now relies on a transitive include.

Location: src/logging.h:27 (base).

🔵 Suggestion · Test category-specific debug selection with global log levels

logging_tests.cpp:256 still tests the global level only with bare -debug. No case checks -debug=net with a global trace level, or that a -debugexclude category stays disabled. The no-debug cases only partly cover the disabled-category path.

Location: src/test/logging_tests.cpp:254 (head).

Review coverage was incomplete.


Reviewed: d5df90e17fd1 · Full review report · Previous reports

permalink

<!-- forgejo-review-bot:bitcoin/bitcoin --> <!-- ralph-engine:current:7ba49ca38b129bc35f71e566efbd136b17ae87b582376d9eebd04f18959e8274:9b5e0237a3fe9e1d05225291551198f07780ddb92e41e55ade9e98c2687fc127 --> <!-- ralph-base:3c51322d9f95225d683a8d438a1dcde970ed5c11 --> <!-- ralph-head:d5df90e17fd1dac8e9be7f90f59802ada6b5ce0b --> <!-- ralph-case:d47268cf0950fd74eb45d89218a1cd25e6b51766c30d70919e216a565a8e08ff --> **🟠 Minor · `-loglevel` results depend on option order** Mixing global and per-category `-loglevel` values can silently lose or add debug/trace output, depending on option order. Location: [`src/init/common.cpp:73`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/d5df90e17fd1dac8e9be7f90f59802ada6b5ce0b/src/init/common.cpp#L73>) (head). **🔵 Suggestion · Including an active category lowers its threshold from trace to debug** Including an already-active category now drops its trace output, although the release note describes only re-enabling categories. Location: [`src/rpc/node.cpp:225`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/d5df90e17fd1dac8e9be7f90f59802ada6b5ce0b/src/rpc/node.cpp#L225>) (head). **🔵 Suggestion · An `info` threshold changes category status and startup defaults** With `-debug=<cat> -loglevel=info`, category status, debug-log shrinking, and GUI details change at startup, despite unchanged log output. Location: [`src/init/common.cpp:129`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/d5df90e17fd1dac8e9be7f90f59802ada6b5ce0b/src/init/common.cpp#L129>) (head). **🔵 Suggestion · `logging.h` uses `std::unordered_map` without including its header** `LogRateLimiter` still declares an `std::unordered_map` member, so `logging.h` now relies on a transitive include. Location: [`src/logging.h:27`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/6ed5aad06111177c39f9b9f07a52634476380ae1/src/logging.h#L27>) (base). **🔵 Suggestion · Test category-specific debug selection with global log levels** logging_tests.cpp:256 still tests the global level only with bare -debug. No case checks -debug=net with a global trace level, or that a -debugexclude category stays disabled. The no-debug cases only partly cover the disabled-category path. Location: [`src/test/logging_tests.cpp:254`](<https://git.fish.foo/bitcoin/bitcoin/src/commit/d5df90e17fd1dac8e9be7f90f59802ada6b5ce0b/src/test/logging_tests.cpp#L254>) (head). Review coverage was incomplete. <!-- Review tier: sensitive --> --- Reviewed: [`d5df90e17fd1`](<https://git.fish.foo/bitcoin/bitcoin/commit/d5df90e17fd1dac8e9be7f90f59802ada6b5ce0b>) · [Full review report](<https://review.fish.foo/traces/35322-d5df90e17fd1dac8e9be7f90f59802ada6b5ce0b-1796-3.html>) · [Previous reports](<https://review.fish.foo/traces/35322/>) [permalink](<https://review.fish.foo/traces/35322-d5df90e17fd1dac8e9be7f90f59802ada6b5ce0b-1796-3.html>)
DrahtBot commented 2026-10-01 01:21:07 +00:00 (Migrated from github.com)

🚧 At least one of the CI tasks failed.
Task iwyu: https://github.com/bitcoin/bitcoin/actions/runs/36794620285/job/110155093409
LLM reason (✨ experimental): CI failed because iwyu reported an include-issues failure (it edited files and the script intentionally returned non-zero: “Failure generated from IWYU”).

Hints

Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:

  • Possibly due to a silent merge conflict (the changes in this pull request being
    incompatible with the current code in the target branch). If so, make sure to rebase on the latest
    commit of the target branch.

  • A sanitizer issue, which can only be found by compiling with the sanitizer and running the
    affected test.

  • An intermittent issue.

Leave a comment here, if you need help tracking down a confusing failure.

<!--85328a0da195eb286784d51f73fa0af9--> 🚧 At least one of the CI tasks failed. <sub>Task `iwyu`: https://github.com/bitcoin/bitcoin/actions/runs/36794620285/job/110155093409</sub> <sub>LLM reason (✨ experimental): CI failed because `iwyu` reported an include-issues failure (it edited files and the script intentionally returned non-zero: “Failure generated from IWYU”).</sub> <details><summary>Hints</summary> Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example: * Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch. * A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test. * An intermittent issue. Leave a comment here, if you need help tracking down a confusing failure. </details>
DrahtBot commented 2026-10-08 16:28:47 +00:00 (Migrated from github.com)

🐙 This pull request conflicts with the target branch and needs rebase.

<!--cf906140f33d8803c4a75a2196329ecb--> 🐙 This pull request conflicts with the target branch and [needs rebase](https://github.com/bitcoin/bitcoin/blob/master/CONTRIBUTING.md#rebasing-changes).
DrahtBot commented 2026-10-30 14:07:51 +00:00 (Migrated from github.com)

🚧 At least one of the CI tasks failed.
Task 32 bit ARM: https://github.com/bitcoin/bitcoin/actions/runs/41053854619/job/124056320251
LLM reason (✨ experimental): CI failed because CTest tried to execute ARM-built test binaries on the host, producing shell syntax errors in four tests.

Hints

Try to run the tests locally, according to the documentation. However, a CI failure may still
happen due to a number of reasons, for example:

  • Possibly due to a silent merge conflict (the changes in this pull request being
    incompatible with the current code in the target branch). If so, make sure to rebase on the latest
    commit of the target branch.

  • A sanitizer issue, which can only be found by compiling with the sanitizer and running the
    affected test.

  • An intermittent issue.

Leave a comment here, if you need help tracking down a confusing failure.

<!--85328a0da195eb286784d51f73fa0af9--> 🚧 At least one of the CI tasks failed. <sub>Task `32 bit ARM`: https://github.com/bitcoin/bitcoin/actions/runs/41053854619/job/124056320251</sub> <sub>LLM reason (✨ experimental): CI failed because CTest tried to execute ARM-built test binaries on the host, producing shell syntax errors in four tests.</sub> <details><summary>Hints</summary> Try to run the tests locally, according to the documentation. However, a CI failure may still happen due to a number of reasons, for example: * Possibly due to a silent merge conflict (the changes in this pull request being incompatible with the current code in the target branch). If so, make sure to rebase on the latest commit of the target branch. * A sanitizer issue, which can only be found by compiling with the sanitizer and running the affected test. * An intermittent issue. Leave a comment here, if you need help tracking down a confusing failure. </details>
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
2 participants
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
bitcoin/bitcoin!35322
No description provided.