2018-09-14 13:59:02 +02:00
|
|
|
// Copyright (c) 2018 The Dash Core developers
|
|
|
|
// Distributed under the MIT/X11 software license, see the accompanying
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
|
|
|
#include "batchedlogger.h"
|
|
|
|
#include "util.h"
|
|
|
|
|
2019-03-21 07:46:27 +01:00
|
|
|
CBatchedLogger::CBatchedLogger(const std::string& _category, const std::string& _header) :
|
|
|
|
accept(LogAcceptCategory(_category.c_str())), header(_header)
|
2018-09-14 13:59:02 +02:00
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
CBatchedLogger::~CBatchedLogger()
|
|
|
|
{
|
|
|
|
Flush();
|
|
|
|
}
|
|
|
|
|
|
|
|
void CBatchedLogger::Flush()
|
|
|
|
{
|
2019-03-21 07:46:27 +01:00
|
|
|
if (!accept || msg.empty()) {
|
2018-09-14 13:59:02 +02:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
LogPrintStr(strprintf("%s:\n%s", header, msg));
|
|
|
|
msg.clear();
|
|
|
|
}
|