-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain_logger.cpp
More file actions
34 lines (30 loc) · 841 Bytes
/
main_logger.cpp
File metadata and controls
34 lines (30 loc) · 841 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
#include "ts_logger.h"
int main()
{
auto& logger = utilities::logger::get_instance();
logger.set_level(utilities::log_level::debug);
// Start logging from multiple threads, multiple logger to a single writer thread
std::vector<std::jthread> threads;
for (int i = 0; i < 5; ++i)
{
threads.emplace_back([&logger, i]()
{
for (int j = 0; j < 10; ++j)
{
logger.write(utilities::log_level::info, "Message from thread ", i, " iteration ", j);
std::this_thread::sleep_for(std::chrono::milliseconds(10));
}
});
}
// press 'q' to shutdown logging
char input;
while (std::cin >> input)
{
if (input == 'q')
{
logger.shutdown();
break;
}
}
return 0;
}