-
Notifications
You must be signed in to change notification settings - Fork 1
/
TextLog.h
44 lines (36 loc) · 992 Bytes
/
TextLog.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
#pragma once
#include <thread>
#include <string>
#include <deque>
#include <mutex>
#include <string>
#include "ITrackLog.h"
using namespace std;
class TextLog : public ITrackLog
{
public:
static TextLog& Singleton();
~TextLog();
virtual void Start();
virtual void Stop();
virtual void Write(const std::string& fname, const std::string& msg, int level = LOGLEVEL::LL_INFO);
private:
struct LogItem
{
LogItem(const string& f = "", const string& m = "", int lv = LOGLEVEL::LL_INFO)
:file(f), message(m), level(lv)
{}
string file;
string message;
int level;
};
TextLog(int lev = LOGLEVEL::LL_INFO);
bool PopOneLogItem(LogItem& item);
void ProcRun();
private:
bool m_RunFlag;
std::thread m_thrdLog;
int m_filterLev;
std::deque<LogItem> m_logQue;
mutable std::mutex m_logMutex;
};