Line data Source code
1 : // Copyright (c) 2018-2025 The Dash Core developers 2 : // Distributed under the MIT/X11 software license, see the accompanying 3 : // file COPYING or http://www.opensource.org/licenses/mit-license.php. 4 : 5 : #include <batchedlogger.h> 6 : 7 0 : CBatchedLogger::CBatchedLogger(BCLog::LogFlags category, BCLog::Level level, const std::string& logging_function, 8 : const std::string& source_file, int source_line) : 9 0 : m_accept{LogAcceptCategory(category, level)}, 10 0 : m_category{category}, 11 0 : m_level{level}, 12 0 : m_logging_function{logging_function}, 13 0 : m_source_file{source_file}, 14 0 : m_source_line{source_line} 15 0 : { 16 0 : } 17 : 18 0 : CBatchedLogger::~CBatchedLogger() 19 0 : { 20 0 : Flush(); 21 0 : } 22 : 23 0 : void CBatchedLogger::Flush() 24 : { 25 0 : if (!m_accept || m_msg.empty()) { 26 0 : return; 27 : } 28 0 : LogInstance().LogPrintStr(m_msg, m_logging_function, m_source_file, m_source_line, m_category, m_level); 29 0 : m_msg.clear(); 30 0 : }