-
Notifications
You must be signed in to change notification settings - Fork 16
/
logger_test.cpp
49 lines (44 loc) · 1.15 KB
/
logger_test.cpp
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
#include <thread>
#include <list>
#include "logger.h"
using namespace std;
using namespace logger;
int main()
{
list<shared_ptr<thread>> oThreads;
/*
* console
*/
for (int i = 0; i < 10; i++)
{
oThreads.push_back(shared_ptr<thread>(new thread([=]() {
for (int j = 0; j < 100; ++j)
debug() << "Thread " << i << ", Message " << j;
})));
}
for (int i = 0; i < 100; i++)
debug() << "Main thread, Message " << i;
for (auto oThread : oThreads)
oThread->join();
debug(Level::Info) << "output to console, done.";
debug(Level::Info) << "press any to continue this test.";
getchar();
oThreads.clear();
/*
* file log
*/
for (int i = 0; i < 10; i++)
{
oThreads.push_back(shared_ptr<thread>(new thread([=]() {
for (int j = 0; j < 100; ++j)
record() << "Thread " << i << ", Message " << j;
})));
}
for (int i = 0; i < 100; i++)
record() << "Main thread, Message " << i;
for (auto oThread : oThreads)
oThread->join();
debug(Level::Info) << "done.";
getchar();
return 0;
}