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 87258 : CBatchedLogger::CBatchedLogger(BCLog::LogFlags category, BCLog::Level level, const std::string& logging_function, 8 : const std::string& source_file, int source_line) : 9 87258 : m_accept{LogAcceptCategory(category, level)}, 10 87258 : m_category{category}, 11 87258 : m_level{level}, 12 87258 : m_logging_function{logging_function}, 13 87258 : m_source_file{source_file}, 14 87258 : m_source_line{source_line} 15 87258 : { 16 87258 : } 17 : 18 87259 : CBatchedLogger::~CBatchedLogger() 19 87259 : { 20 87259 : Flush(); 21 87259 : } 22 : 23 122442 : void CBatchedLogger::Flush() 24 : { 25 122442 : if (!m_accept || m_msg.empty()) { 26 59893 : return; 27 : } 28 62549 : LogInstance().LogPrintStr(m_msg, m_logging_function, m_source_file, m_source_line, m_category, m_level); 29 62549 : m_msg.clear(); 30 122442 : }