test: Clarify logging_SeverityLevels test
What changed, and why it matters
This commit only changes a test file to make the unit test easier to read. It explicitly sets the log level to Debug inside the test, adds one extra debug log line, and replaces a longer logging macro with shorter ones. There is no change to the actual Bitcoin Core software that users run, and no security issue is present.
No security action needed. This is a test-only readability improvement.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The commit modifies src/test/logging_tests.cpp in the logging_SeverityLevels test case. It adds LogInstance().SetLogLevel(BCLog::Level::Debug) for self-containment, adds a LogDebug(BCLog::HTTP, …) line, and replaces two LogPrintLevel(…, BCLog::Level::Trace/Debug, …) calls with the equivalent LogTrace and LogDebug macros. The expected output vector is updated accordingly. No production code is touched.
Changed components
src/test/logging_tests.cppInspect captured patch +5 / −2
diff --git a/src/test/logging_tests.cpp b/src/test/logging_tests.cpp
index 42658e94..809f27b2 100644
--- a/src/test/logging_tests.cpp
+++ b/src/test/logging_tests.cpp
@@ -203,22 +203,25 @@ BOOST_FIXTURE_TEST_CASE(logging_LogPrintMacros_CategoryName, LogSetup)
BOOST_FIXTURE_TEST_CASE(logging_SeverityLevels, LogSetup)
{
+ LogInstance().SetLogLevel(BCLog::Level::Debug);
LogInstance().EnableCategory(BCLog::LogFlags::ALL);
LogInstance().SetCategoryLogLevel(/*category_str=*/"net", /*level_str=*/"info");
// Global log level
LogPrintLevel(BCLog::HTTP, BCLog::Level::Info, "foo1: %s\n", "bar1");
- LogPrintLevel(BCLog::MEMPOOL, BCLog::Level::Trace, "foo2: %s. This log level is lower than the global one.\n", "bar2");
+ LogTrace(BCLog::HTTP, "trace_%s. This log level is lower than the global one.", 2);
+ LogDebug(BCLog::HTTP, "debug_%s", 3);
LogPrintLevel(BCLog::VALIDATION, BCLog::Level::Warning, "foo3: %s\n", "bar3");
LogPrintLevel(BCLog::RPC, BCLog::Level::Error, "foo4: %s\n", "bar4");
// Category-specific log level
LogPrintLevel(BCLog::NET, BCLog::Level::Warning, "foo5: %s\n", "bar5");
- LogPrintLevel(BCLog::NET, BCLog::Level::Debug, "foo6: %s. This log level is the same as the global one but lower than the category-specific one, which takes precedence. \n", "bar6");
+ LogDebug(BCLog::NET, "debug_%s. This log level is the same as the global one but lower than the category-specific one, which takes precedence.", 6);
LogPrintLevel(BCLog::NET, BCLog::Level::Error, "foo7: %s\n", "bar7");
std::vector<std::string> expected = {
"[http:info] foo1: bar1",
+ "[http] debug_3",
"[validation:warning] foo3: bar3",
"[rpc:error] foo4: bar4",
"[net:warning] foo5: bar5",
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.