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.
|
|
|
|
|
|
|
|
#ifndef DASH_BATCHEDLOGGER_H
|
|
|
|
#define DASH_BATCHEDLOGGER_H
|
|
|
|
|
|
|
|
#include "tinyformat.h"
|
|
|
|
|
|
|
|
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();
|
|
|
|
};
|
|
|
|
|
2019-01-09 07:29:57 +01:00
|
|
|
#endif//DASH_BATCHEDLOGGER_H
|