mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-01-19 23:03:45 +01:00
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.
This commit is contained in:
@@ -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",
|
||||
|
||||
Reference in New Issue
Block a user