What changed, and why it matters
This commit removes support for the 'libevent' logging category in Bitcoin Core. It is a routine cleanup: the category is marked as deprecated, attempts to enable it are ignored with a warning, and it is excluded from the special 'all' logging flag. There is no security issue here.
No security action required. This is a benign deprecation and cleanup commit.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The patch deprecates BCLog::LIBEVENT by aliasing it to a new DEPRECATED mask and removing it from ALL. EnableCategory/DisableCategory now warn and return true when a deprecated category is requested, preventing startup failures from stale config files. The RPC logging() example is updated and dead libevent update logic is removed. Tests are adjusted accordingly.
Changed components
src/logging.cppsrc/logging/categories.hsrc/rpc/node.cppsrc/test/logging_tests.cppsrc/test/util/setup_common.cpptest/functional/rpc_misc.pytest/functional/test_framework/test_node.pyInspect captured patch +31 / −16
diff --git a/src/logging.cpp b/src/logging.cpp
index 4b6fd96b..0dd760b9 100644
--- a/src/logging.cpp
+++ b/src/logging.cpp
@@ -133,6 +133,11 @@ void BCLog::Logger::EnableCategory(BCLog::LogFlags flag)
bool BCLog::Logger::EnableCategory(std::string_view str)
{
if (const auto flag{GetLogCategory(str)}) {
+ if (*flag & DEPRECATED){
+ LogWarning("The logging category `%s` is deprecated, can not be enabled, and will be removed in a future version", str);
+ // Deprecated does not mean unsupported, which may prevent startup
+ return true;
+ }
EnableCategory(*flag);
return true;
}
@@ -147,6 +152,11 @@ void BCLog::Logger::DisableCategory(BCLog::LogFlags flag)
bool BCLog::Logger::DisableCategory(std::string_view str)
{
if (const auto flag{GetLogCategory(str)}) {
+ if (*flag & DEPRECATED){
+ LogWarning("The logging category `%s` is deprecated and will be removed in a future version", str);
+ // Deprecated does not mean unsupported, which may prevent startup
+ return true;
+ }
DisableCategory(*flag);
return true;
}
diff --git a/src/logging/categories.h b/src/logging/categories.h
index dff00ada..b4c6b1a1 100644
--- a/src/logging/categories.h
+++ b/src/logging/categories.h
@@ -46,9 +46,10 @@ enum LogFlags : CategoryMask {
TXPACKAGES = (CategoryMask{1} << 28),
KERNEL = (CategoryMask{1} << 29),
PRIVBROADCAST = (CategoryMask{1} << 30),
- ALL = ~NONE,
+ DEPRECATED = LIBEVENT,
+ // Remove deprecated categories from ALL
+ ALL = ~DEPRECATED,
};
-
} // namespace BCLog
#endif // BITCOIN_LOGGING_CATEGORIES_H
diff --git a/src/rpc/node.cpp b/src/rpc/node.cpp
index 34ef8eb1..6d0d5511 100644
--- a/src/rpc/node.cpp
+++ b/src/rpc/node.cpp
@@ -248,26 +248,16 @@ static RPCMethod logging()
},
RPCExamples{
HelpExampleCli("logging", "\"[\\\"all\\\"]\" \"[\\\"http\\\"]\"")
- + HelpExampleRpc("logging", "[\"all\"], [\"libevent\"]")
+ + HelpExampleRpc("logging", "[\"all\"], [\"leveldb\"]")
},
[](const RPCMethod& self, const JSONRPCRequest& request) -> UniValue
{
- BCLog::CategoryMask original_log_categories = LogInstance().GetCategoryMask();
if (request.params[0].isArray()) {
EnableOrDisableLogCategories(request.params[0], true);
}
if (request.params[1].isArray()) {
EnableOrDisableLogCategories(request.params[1], false);
}
- BCLog::CategoryMask updated_log_categories = LogInstance().GetCategoryMask();
- BCLog::CategoryMask changed_log_categories = original_log_categories ^ updated_log_categories;
-
- // Update libevent logging if BCLog::LIBEVENT has changed.
- if (changed_log_categories & BCLog::LIBEVENT) {
- // Currently no modules in the codebase produce libevent log messages.
- // To redirect libevent messages to our own logs see commit 8b2d6edaa9fbfb6344ca51edd0b3655b451cbcac
- // in https://github.com/bitcoin/bitcoin/pull/6695
- }
UniValue result(UniValue::VOBJ);
for (const auto& logCatActive : LogInstance().LogCategoriesList()) {
diff --git a/src/test/logging_tests.cpp b/src/test/logging_tests.cpp
index 5595fe16..29cbe8e7 100644
--- a/src/test/logging_tests.cpp
+++ b/src/test/logging_tests.cpp
@@ -167,7 +167,11 @@ BOOST_FIXTURE_TEST_CASE(logging_LogPrintMacros_CategoryName, LogSetup)
for (const auto& category_name : category_names) {
const auto trimmed_category_name = TrimString(category_name);
const auto category{*Assert(BCLog::Logger::GetLogCategory(trimmed_category_name))};
- expected_category_names.emplace_back(category, trimmed_category_name);
+ if (category & BCLog::LogFlags::ALL) {
+ expected_category_names.emplace_back(category, trimmed_category_name);
+ } else {
+ BOOST_CHECK(category & BCLog::LogFlags::DEPRECATED);
+ }
}
std::vector<std::string> expected;
diff --git a/src/test/util/setup_common.cpp b/src/test/util/setup_common.cpp
index 9e82eae8..830fca0e 100644
--- a/src/test/util/setup_common.cpp
+++ b/src/test/util/setup_common.cpp
@@ -165,7 +165,6 @@ BasicTestingSetup::BasicTestingSetup(const ChainType chainType, TestOpts opts)
"-logthreadnames",
"-loglevel=trace",
"-debug",
- "-debugexclude=libevent",
"-debugexclude=leveldb",
},
opts.extra_args);
diff --git a/test/functional/rpc_misc.py b/test/functional/rpc_misc.py
index 6e4c908d..5cc3a29c 100755
--- a/test/functional/rpc_misc.py
+++ b/test/functional/rpc_misc.py
@@ -120,6 +120,18 @@ class RpcMiscTest(BitcoinTestFramework):
# Specifying an unknown index name returns an empty result
assert_equal(node.getindexinfo("foo"), {})
+ # Test a deprecated category
+ node.logging(include=['all'])
+ for category, value in node.logging().items():
+ # Everything True except one...
+ assert_equal(value, category != "libevent")
+ with self.nodes[0].assert_debug_log(["The logging category `libevent` is deprecated"]):
+ node.logging(include=['libevent'])
+ assert_equal(node.logging()['libevent'], False)
+ with self.nodes[0].assert_debug_log(["The logging category `libevent` is deprecated"]):
+ node.logging(exclude=['libevent'])
+ assert_equal(node.logging()['libevent'], False)
+
if __name__ == '__main__':
RpcMiscTest(__file__).main()
diff --git a/test/functional/test_framework/test_node.py b/test/functional/test_framework/test_node.py
index 77a7fcb4..a7c140a5 100755
--- a/test/functional/test_framework/test_node.py
+++ b/test/functional/test_framework/test_node.py
@@ -142,7 +142,6 @@ class TestNode():
f"-datadir={self.datadir_path}",
"-logtimemicros",
"-debug",
- "-debugexclude=libevent",
"-debugexclude=leveldb",
"-debugexclude=rand",
"-uacomment=testnode%d" % i, # required for subversion uniqueness across peers
Why this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.