/
LogWriter.h
46 lines (35 loc) · 1018 Bytes
/
LogWriter.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
41
42
43
44
45
46
#pragma once
#include <set>
#include <map>
#include "ilogwriter.h"
#include "LogStream.h"
namespace applog
{
class LogWriter :
public ILogWriter
{
private:
// The set of unique log devices
typedef std::set<ILogDevice*> LogDevices;
LogDevices _devices;
std::map<LogLevel, LogStream> _streams;
public:
LogWriter();
/**
* greebo: Writes the given buffer p with the given length to the
* various output devices (i.e. Console and Log file).
*/
void write(const char* p, std::size_t length, LogLevel level) override;
std::ostream& getLogStream(LogLevel level) override;
std::mutex& getStreamLock() override;
/**
* greebo: Use these methods to attach/detach a log device from the
* writer class. After attaching a device, all log output
* will be written to it.
*/
void attach(ILogDevice* device) override;
void detach(ILogDevice* device) override;
// Contains the static singleton instance of this writer
static LogWriter& Instance();
};
} // namespace applog