Inside Bitcoin
Opening the selected file…
Inside Bitcoin
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1// Copyright (c) 2019-present The Bitcoin Core developers2// Distributed under the MIT software license, see the accompanying3// file COPYING or http://www.opensource.org/licenses/mit-license.php.5#ifndef BITCOIN_TEST_UTIL_LOGGING_H6#define BITCOIN_TEST_UTIL_LOGGING_H8#include <util/macros.h>10#include <functional>11#include <list>12#include <string>14class DebugLogHelper15{16public:17//! Custom match checking function.18//!19//! Invoked with pointers to lines containing matching strings, and with20//! null if check_found() is called without any successful match.21//!22//! Can return true to enable default DebugLogHelper behavior of:23//! (1) ending search after first successful match, and24//! (2) raising an error in check_found if no match was found25//! Can return false to do the opposite in either case.26using MatchFn = std::function<bool(const std::string* line)>;28explicit DebugLogHelper(std::string message, MatchFn match = [](const std::string*){ return true; });30DebugLogHelper(const DebugLogHelper&) = delete;31DebugLogHelper& operator=(const DebugLogHelper&) = delete;33~DebugLogHelper();35private:36const std::string m_message;37bool m_found{false};38std::list<std::function<void(const std::string&)>>::iterator m_print_connection;39MatchFn m_match;40};42#define ASSERT_DEBUG_LOG(message) DebugLogHelper BITCOIN_UNIQUE_NAME(debugloghelper)(message)44#endif // BITCOIN_TEST_UTIL_LOGGING_H
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.