LCOV - code coverage report
Current view: top level - src/test/util - logging.cpp (source / functions) Coverage Total Hit
Test: total_coverage.info Lines: 86.7 % 15 13
Test Date: 2025-10-04 05:03:45 Functions: 100.0 % 3 3
Branches: 70.0 % 20 14

             Branch data     Line data    Source code
       1                 :             : // Copyright (c) 2019-2021 The Bitcoin Core developers
       2                 :             : // Distributed under the MIT software license, see the accompanying
       3                 :             : // file COPYING or http://www.opensource.org/licenses/mit-license.php.
       4                 :             : 
       5                 :             : #include <test/util/logging.h>
       6                 :             : 
       7                 :             : #include <logging.h>
       8                 :             : #include <noui.h>
       9                 :             : #include <tinyformat.h>
      10                 :             : 
      11                 :             : #include <cstdlib>
      12                 :             : #include <iostream>
      13                 :             : 
      14                 :          62 : DebugLogHelper::DebugLogHelper(std::string message, MatchFn match)
      15                 :          62 :     : m_message{std::move(message)}, m_match(std::move(match))
      16                 :             : {
      17   [ +  -  +  - ]:          62 :     m_print_connection = LogInstance().PushBackCallback(
      18         [ +  - ]:          62 :         [this](const std::string& s) {
      19         [ +  + ]:        1006 :             if (m_found) return;
      20   [ -  +  +  +  :        1911 :             m_found = s.find(m_message) != std::string::npos && m_match(&s);
                   +  + ]
      21                 :             :         });
      22         [ +  - ]:          62 :     noui_test_redirect();
      23                 :          62 : }
      24                 :             : 
      25                 :         124 : DebugLogHelper::~DebugLogHelper()
      26                 :             : {
      27                 :          62 :     noui_reconnect();
      28                 :          62 :     LogInstance().DeleteCallback(m_print_connection);
      29   [ +  +  -  + ]:          62 :     if (!m_found && m_match(nullptr)) {
      30                 :           0 :         tfm::format(std::cerr, "Fatal error: expected message not found in the debug log: '%s'\n", m_message);
      31                 :           0 :         std::abort();
      32                 :             :     }
      33                 :          62 : }
        

Generated by: LCOV version 2.0-1