WhisperCom/loguru_example/loguru_example.hpp
Dominik Meyer f637c3cee6 Squashed 'libs/loguru/' content from commit 9c2fea0d
git-subtree-dir: libs/loguru
git-subtree-split: 9c2fea0d4530657f23259be4132f8101c98b579e
2021-08-19 17:03:04 +02:00

27 lines
618 B
C++

#include <chrono>
#include <thread>
#include "../loguru.hpp"
inline void sleep_ms(int ms)
{
VLOG_F(2, "Sleeping for %d ms", ms);
std::this_thread::sleep_for(std::chrono::milliseconds(ms));
}
inline void complex_calculation()
{
LOG_SCOPE_F(INFO, "complex_calculation");
LOG_F(INFO, "Starting time machine...");
sleep_ms(200);
LOG_F(WARNING, "The flux capacitor is not getting enough power!");
sleep_ms(400);
LOG_F(INFO, "Lighting strike!");
VLOG_F(1, "Found 1.21 gigawatts...");
sleep_ms(400);
std::thread([](){
loguru::set_thread_name("the past");
LOG_F(ERROR, "We ended up in 1985!");
}).join();
}