File tree Expand file tree Collapse file tree 2 files changed +14
-12
lines changed Expand file tree Collapse file tree 2 files changed +14
-12
lines changed Original file line number Diff line number Diff line change 88#include < noui.h>
99#include < tinyformat.h>
1010
11- #include < stdexcept>
11+ #include < cstdlib>
12+ #include < iostream>
1213
1314DebugLogHelper::DebugLogHelper (std::string message, MatchFn match)
1415 : m_message{std::move (message)}, m_match(std::move(match))
@@ -21,11 +22,12 @@ DebugLogHelper::DebugLogHelper(std::string message, MatchFn match)
2122 noui_test_redirect ();
2223}
2324
24- void DebugLogHelper::check_found ()
25+ DebugLogHelper::~DebugLogHelper ()
2526{
2627 noui_reconnect ();
2728 LogInstance ().DeleteCallback (m_print_connection);
2829 if (!m_found && m_match (nullptr )) {
29- throw std::runtime_error (strprintf (" '%s' not found in debug log\n " , m_message));
30+ tfm::format (std::cerr, " Fatal error: expected message not found in the debug log: '%s'\n " , m_message);
31+ std::abort ();
3032 }
3133}
Original file line number Diff line number Diff line change 1313
1414class DebugLogHelper
1515{
16- const std::string m_message;
17- bool m_found{false };
18- std::list<std::function<void (const std::string&)>>::iterator m_print_connection;
19-
16+ public:
2017 // ! Custom match checking function.
2118 // !
2219 // ! Invoked with pointers to lines containing matching strings, and with
@@ -27,13 +24,16 @@ class DebugLogHelper
2724 // ! (2) raising an error in check_found if no match was found
2825 // ! Can return false to do the opposite in either case.
2926 using MatchFn = std::function<bool (const std::string* line)>;
30- MatchFn m_match;
31-
32- void check_found ();
3327
34- public:
3528 explicit DebugLogHelper (std::string message, MatchFn match = [](const std::string*){ return true ; });
36- ~DebugLogHelper () noexcept (false ) { check_found (); }
29+
30+ ~DebugLogHelper ();
31+
32+ private:
33+ const std::string m_message;
34+ bool m_found{false };
35+ std::list<std::function<void (const std::string&)>>::iterator m_print_connection;
36+ MatchFn m_match;
3737};
3838
3939#define ASSERT_DEBUG_LOG (message ) DebugLogHelper UNIQUE_NAME (debugloghelper)(message)
You can’t perform that action at this time.
0 commit comments