upm/examples/c++/logger.cxx

35 lines
631 B
C++
Raw Normal View History

#include <thread>
#include <vector>
2018-05-21 19:13:18 +03:00
#include "upm_logger.hpp"
using namespace upm;
void print()
{
UPM_LOG(LOG_DEBUG) << "Thread " << std::this_thread::get_id() << ": running loop with 3 iterations";
for (int i = 0; i < 4; ++i) {
UPM_LOG(LOG_DEBUG) << std::this_thread::get_id() << ": i = " << i;
}
}
2018-05-21 19:13:18 +03:00
int main()
{
std::vector<std::thread> threads;
2018-05-21 19:13:18 +03:00
2018-05-22 17:33:49 +03:00
UPM_LOGGER::LogLevel() = LOG_INFO;
2018-05-21 19:13:18 +03:00
UPM_LOG(LOG_WARNING) << "Testing the upm logger";
2018-05-21 19:13:18 +03:00
// Launching 5 threads
for (int i = 0; i < 5; ++i) {
threads.push_back(std::thread(print));
}
for (auto& thread : threads) {
thread.join();
2018-05-21 19:13:18 +03:00
}
return 0;
}