-
Notifications
You must be signed in to change notification settings - Fork 0
/
Logger.h
40 lines (31 loc) · 826 Bytes
/
Logger.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
#ifndef LOGGER_H
#define LOGGER_H
#include <string>
#include "common.h"
class Logger {
public:
typedef std::function<void(std::string const &)> MESSAGE_ACCEPTOR;
public:
Logger(
MESSAGE_ACCEPTOR logTimeAcceptor,
int maxMessageLength,
int capacity) :
logTimeAcceptor(logTimeAcceptor),
maxMessageLength(maxMessageLength),
capacity(capacity),
messages(new std::string[capacity]),
nextMessageNumber(0) {}
void log(std::string const &message);
template <typename ... ARGS>
void log(std::string const &format, ARGS ... args) {
log(formatString(format, args ...));
}
void readStoredMessages(MESSAGE_ACCEPTOR messageAcceptor);
private:
MESSAGE_ACCEPTOR logTimeAcceptor;
int const maxMessageLength;
int const capacity;
std::unique_ptr<std::string[]> messages;
int nextMessageNumber;
};
#endif