aboutsummaryrefslogtreecommitdiff
path: root/src/test/lib/logging.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/test/lib/logging.h')
-rw-r--r--src/test/lib/logging.h29
1 files changed, 29 insertions, 0 deletions
diff --git a/src/test/lib/logging.h b/src/test/lib/logging.h
new file mode 100644
index 0000000000..ea1b0ad6f0
--- /dev/null
+++ b/src/test/lib/logging.h
@@ -0,0 +1,29 @@
+// Copyright (c) 2019 The Bitcoin Core developers
+// Distributed under the MIT software license, see the accompanying
+// file COPYING or http://www.opensource.org/licenses/mit-license.php.
+
+#ifndef BITCOIN_TEST_LIB_LOGGING_H
+#define BITCOIN_TEST_LIB_LOGGING_H
+
+#include <util/macros.h>
+
+#include <functional>
+#include <list>
+#include <string>
+
+class DebugLogHelper
+{
+ const std::string m_message;
+ bool m_found{false};
+ std::list<std::function<void(const std::string&)>>::iterator m_print_connection;
+
+ void check_found();
+
+public:
+ DebugLogHelper(std::string message);
+ ~DebugLogHelper() { check_found(); }
+};
+
+#define ASSERT_DEBUG_LOG(message) DebugLogHelper PASTE2(debugloghelper, __COUNTER__)(message)
+
+#endif // BITCOIN_TEST_LIB_LOGGING_H