From fac24bbec85fc930900ff755192a9954c7c2e27c Mon Sep 17 00:00:00 2001 From: MarcoFalke <*~=`'#}+{/-|&$^_@721217.xyz> Date: Fri, 12 Dec 2025 11:32:16 +0100 Subject: [PATCH] test: Clarify logging_SeverityLevels test The test was a bit confusing, because it just referred to the "global log level" without explicitly specifying what it is. The level is set though the LogSetup constructor. However, it is easier to follow unit tests, if they are self-contained. So just set the level to Debug explicitly here. Also, add a new debug_3 log, to further document the intended behavior of the unit test. Also, replace the LogPrintLevel with the shorter and exact replacements LogTrace and LogDebug. --- src/test/logging_tests.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/test/logging_tests.cpp b/src/test/logging_tests.cpp index 42658e940a7..809f27b28ff 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 expected = { "[http:info] foo1: bar1", + "[http] debug_3", "[validation:warning] foo3: bar3", "[rpc:error] foo4: bar4", "[net:warning] foo5: bar5",