| 111 | } |
| 112 | |
| 113 | BOOST_FIXTURE_TEST_CASE(logging_LogPrint, LogSetup) |
| 114 | { |
| 115 | LogInstance().m_log_sourcelocations = true; |
| 116 | |
| 117 | struct Case { |
| 118 | std::string msg; |
| 119 | BCLog::LogFlags category; |
| 120 | BCLog::Level level; |
| 121 | std::string prefix; |
| 122 | SourceLocation loc; |
| 123 | }; |
| 124 | |
| 125 | std::vector<Case> cases = { |
| 126 | {"foo1: bar1", BCLog::NET, BCLog::Level::Debug, "[net] ", SourceLocation{__func__}}, |
| 127 | {"foo2: bar2", BCLog::NET, BCLog::Level::Info, "[net:info] ", SourceLocation{__func__}}, |
| 128 | {"foo3: bar3", BCLog::ALL, BCLog::Level::Debug, "[debug] ", SourceLocation{__func__}}, |
| 129 | {"foo4: bar4", BCLog::ALL, BCLog::Level::Info, "", SourceLocation{__func__}}, |
| 130 | {"foo5: bar5", BCLog::NONE, BCLog::Level::Debug, "[debug] ", SourceLocation{__func__}}, |
| 131 | {"foo6: bar6", BCLog::NONE, BCLog::Level::Info, "", SourceLocation{__func__}}, |
| 132 | }; |
| 133 | |
| 134 | std::vector<std::string> expected; |
| 135 | for (auto& [msg, category, level, prefix, loc] : cases) { |
| 136 | expected.push_back(tfm::format("[%s:%s] [%s] %s%s", util::RemovePrefix(loc.file_name(), "./"), loc.line(), loc.function_name_short(), prefix, msg)); |
| 137 | LogInstance().LogPrint({.category = category, .level = level, .should_ratelimit = false, .source_loc = std::move(loc), .message = msg}); |
| 138 | } |
| 139 | std::vector<std::string> log_lines{ReadDebugLogLines()}; |
| 140 | BOOST_CHECK_EQUAL_COLLECTIONS(log_lines.begin(), log_lines.end(), expected.begin(), expected.end()); |
| 141 | } |
| 142 | |
| 143 | BOOST_FIXTURE_TEST_CASE(logging_LogPrintMacros, LogSetup) |
| 144 | { |
nothing calls this directly
no test coverage detected