mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-02-05 10:17:30 -05:00
![fanquake](/assets/img/avatar_default.png)
-BEGIN VERIFY SCRIPT- git rm src/util/memory.h sed -i -e 's/MakeUnique/std::make_unique/g' $(git grep -l MakeUnique src) sed -i -e '/#include <util\/memory.h>/d' $(git grep -l '#include <util/memory.h>' src) sed -i -e '/util\/memory.h \\/d' src/Makefile.am -END VERIFY SCRIPT-
31 lines
942 B
C++
31 lines
942 B
C++
// Copyright (c) 2019-2020 The Bitcoin Core developers
|
|
// Distributed under the MIT software license, see the accompanying
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
#include <test/util/logging.h>
|
|
|
|
#include <logging.h>
|
|
#include <noui.h>
|
|
#include <tinyformat.h>
|
|
|
|
#include <stdexcept>
|
|
|
|
DebugLogHelper::DebugLogHelper(std::string message, MatchFn match)
|
|
: m_message{std::move(message)}, m_match(std::move(match))
|
|
{
|
|
m_print_connection = LogInstance().PushBackCallback(
|
|
[this](const std::string& s) {
|
|
if (m_found) return;
|
|
m_found = s.find(m_message) != std::string::npos && m_match(&s);
|
|
});
|
|
noui_test_redirect();
|
|
}
|
|
|
|
void DebugLogHelper::check_found()
|
|
{
|
|
noui_reconnect();
|
|
LogInstance().DeleteCallback(m_print_connection);
|
|
if (!m_found && m_match(nullptr)) {
|
|
throw std::runtime_error(strprintf("'%s' not found in debug log\n", m_message));
|
|
}
|
|
}
|