2019-01-29 15:53:14 +01:00
|
|
|
// Copyright (c) 2018-2019 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
|
|
|
|
2020-03-19 23:46:56 +01:00
|
|
|
#include <tinyformat.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:
|
2019-05-22 23:51:39 +02:00
|
|
|
CBatchedLogger(uint64_t _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
|