diff options
author | Anthony Towns <aj@erisian.com.au> | 2023-09-12 18:13:25 +1000 |
---|---|---|
committer | Anthony Towns <aj@erisian.com.au> | 2023-12-15 11:03:25 +1000 |
commit | 782bb6a05663ad7a53908e910d0f42b49b881e09 (patch) | |
tree | 3153dffa6dc2b5a5c3ad29155af0352a11982757 /src | |
parent | 667ce3e3297645527b07314e1d5a82275fb25845 (diff) | |
download | bitcoin-782bb6a05663ad7a53908e910d0f42b49b881e09.tar.xz |
logging: treat BCLog::ALL like BCLog::NONE
Diffstat (limited to 'src')
-rw-r--r-- | src/logging.cpp | 4 | ||||
-rw-r--r-- | src/test/logging_tests.cpp | 8 |
2 files changed, 9 insertions, 3 deletions
diff --git a/src/logging.cpp b/src/logging.cpp index f6cd404971..6004abf999 100644 --- a/src/logging.cpp +++ b/src/logging.cpp @@ -390,7 +390,9 @@ namespace BCLog { std::string BCLog::Logger::GetLogPrefix(BCLog::LogFlags category, BCLog::Level level) const { - const bool has_category{category != LogFlags::NONE}; + if (category == LogFlags::NONE) category = LogFlags::ALL; + + const bool has_category{category != LogFlags::ALL}; // If there is no category, Info is implied if (!has_category && level == Level::Info) return {}; diff --git a/src/test/logging_tests.cpp b/src/test/logging_tests.cpp index acc52afb45..abc878c5a5 100644 --- a/src/test/logging_tests.cpp +++ b/src/test/logging_tests.cpp @@ -85,8 +85,10 @@ BOOST_FIXTURE_TEST_CASE(logging_LogPrintf_, LogSetup) LogInstance().m_log_sourcelocations = true; LogPrintf_("fn1", "src1", 1, BCLog::LogFlags::NET, BCLog::Level::Debug, "foo1: %s\n", "bar1"); LogPrintf_("fn2", "src2", 2, BCLog::LogFlags::NET, BCLog::Level::Info, "foo2: %s\n", "bar2"); - LogPrintf_("fn3", "src3", 3, BCLog::LogFlags::NONE, BCLog::Level::Debug, "foo3: %s\n", "bar3"); - LogPrintf_("fn4", "src4", 4, BCLog::LogFlags::NONE, BCLog::Level::Info, "foo4: %s\n", "bar4"); + LogPrintf_("fn3", "src3", 3, BCLog::LogFlags::ALL, BCLog::Level::Debug, "foo3: %s\n", "bar3"); + LogPrintf_("fn4", "src4", 4, BCLog::LogFlags::ALL, BCLog::Level::Info, "foo4: %s\n", "bar4"); + LogPrintf_("fn5", "src5", 5, BCLog::LogFlags::NONE, BCLog::Level::Debug, "foo5: %s\n", "bar5"); + LogPrintf_("fn6", "src6", 6, BCLog::LogFlags::NONE, BCLog::Level::Info, "foo6: %s\n", "bar6"); std::ifstream file{tmp_log_path}; std::vector<std::string> log_lines; for (std::string log; std::getline(file, log);) { @@ -97,6 +99,8 @@ BOOST_FIXTURE_TEST_CASE(logging_LogPrintf_, LogSetup) "[src2:2] [fn2] [net:info] foo2: bar2", "[src3:3] [fn3] [debug] foo3: bar3", "[src4:4] [fn4] foo4: bar4", + "[src5:5] [fn5] [debug] foo5: bar5", + "[src6:6] [fn6] foo6: bar6", }; BOOST_CHECK_EQUAL_COLLECTIONS(log_lines.begin(), log_lines.end(), expected.begin(), expected.end()); } |