2023-01-12 22:26:21 +01:00
|
|
|
// Copyright (c) 2018-2022 The Dash Core developers
|
2018-09-14 13:59:02 +02:00
|
|
|
// Distributed under the MIT/X11 software license, see the accompanying
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
2018-04-02 00:30:17 +02:00
|
|
|
#ifndef BITCOIN_BATCHEDLOGGER_H
|
|
|
|
#define BITCOIN_BATCHEDLOGGER_H
|
2018-09-14 13:59:02 +02:00
|
|
|
|
2018-05-01 04:13:30 +02:00
|
|
|
#include <logging.h>
|
2018-09-14 13:59:02 +02:00
|
|
|
|
|
|
|
class CBatchedLogger
|
|
|
|
{
|
|
|
|
private:
|
2019-03-21 07:46:27 +01:00
|
|
|
bool accept;
|
2018-09-14 13:59:02 +02:00
|
|
|
std::string header;
|
|
|
|
std::string msg;
|
|
|
|
public:
|
2018-05-01 04:13:30 +02:00
|
|
|
CBatchedLogger(BCLog::LogFlags _category, const std::string& _header);
|
2018-09-14 13:59:02 +02:00
|
|
|
virtual ~CBatchedLogger();
|
|
|
|
|
|
|
|
template<typename... Args>
|
2019-01-10 11:59:22 +01:00
|
|
|
void Batch(const std::string& fmt, const Args&... args)
|
2018-09-14 13:59:02 +02:00
|
|
|
{
|
2019-03-21 07:46:27 +01:00
|
|
|
if (!accept) {
|
|
|
|
return;
|
|
|
|
}
|
2019-01-10 11:59:22 +01:00
|
|
|
msg += " " + strprintf(fmt, args...) + "\n";
|
2018-09-14 13:59:02 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
void Flush();
|
|
|
|
};
|
|
|
|
|
2018-04-02 00:30:17 +02:00
|
|
|
#endif//BITCOIN_BATCHEDLOGGER_H
|