-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathLogBuffer.cpp
More file actions
62 lines (39 loc) · 773 Bytes
/
Copy pathLogBuffer.cpp
File metadata and controls
62 lines (39 loc) · 773 Bytes
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
#include "LogBuffer.h"
#include <deque>
#include <mutex>
static std::deque<std::wstring> g_lines;
static std::mutex g_mutex;
// numero massimo righe conservate
static constexpr size_t MAX_LOG_LINES = 2000;
void AddLogLine(
const std::wstring& line
)
{
std::lock_guard<std::mutex> lock(
g_mutex
);
g_lines.push_back(
line
);
while (g_lines.size() > MAX_LOG_LINES)
{
g_lines.pop_front();
}
}
std::vector<std::wstring> GetLogLines()
{
std::lock_guard<std::mutex> lock(
g_mutex
);
return std::vector<std::wstring>(
g_lines.begin(),
g_lines.end()
);
}
void ClearLogBuffer()
{
std::lock_guard<std::mutex> lock(
g_mutex
);
g_lines.clear();
}