-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLogFrame.h
81 lines (65 loc) · 2 KB
/
LogFrame.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
//---------------------------------------------------------------------------
#pragma once
#ifndef LogFrameH
#define LogFrameH
//---------------------------------------------------------------------------
#define _LOG_BUFFER_MAX_ 4*1024
//#define _LOG_FILE_PATH "./OperationLog.txt"
//--------------------------------------------------
#include <sstream>
#include <string>
#include <windows.h>
#include <queue>
using namespace std;
//------------------------------Class:Tostringstream-----------------------------------------
class Tostringstream{
public:
Tostringstream();
Tostringstream(const Tostringstream& r);
~Tostringstream();
Tostringstream operator=(const Tostringstream& r);
public:
ostringstream stream;
public:
void clear();
void realease();
};
//----------------------------------------Class:LogThread---------------------------------------
class LogThread{
public:
unsigned logThreadId;
Tostringstream logThreadStream;
public:
LogThread();
LogThread(unsigned threadId, Tostringstream ostringstream);
~LogThread();
LogThread(const LogThread& r);
LogThread operator=(const LogThread& r);
};
//-----------------------------------------Class:RunningLog-------------------------------------
class RunningLog{
private:
RunningLog();
RunningLog(const RunningLog& r);
RunningLog operator=(const RunningLog& r);
static RunningLog* runningLogInstance;
public:
~RunningLog();
static void writeLog(const char* _log);
static void writeLog(const char* _log,int lineNum);
static void releaseInstance();
class RunningLogGarbo{
public:
RunningLogGarbo();
~RunningLogGarbo();
};
static RunningLogGarbo runningGarbo;
private:
Tostringstream _osBuffer;
queue<LogThread> logThreadQueue;
HANDLE mutex;
void flushToLogBeforeExit();
friend unsigned __stdcall requestToWriteLogFileOnce(void* pvParam);
};
//--------------------------------------------------------------------------
#endif