#ifndef DEBUG_H #define DEBUG_H #include #include #include #include "Time.h" /** quick and dirty workaround */ static decltype(Time::tick()) LogLastTick; class Log { public: static void add(const char* comp, const std::string what, const bool nl = true) { addComp(comp); std::cout << what; if (nl) {std::cout << std::endl;} else {std::cout << std::flush;} } static void add(const std::string& component, const std::string what, const bool nl = true) { addComp(component.c_str()); std::cout << what; if (nl) {std::cout << std::endl;} else {std::cout << std::flush;} } static void tick() { LogLastTick = Time::tick(); } static void tock() { const auto cur = Time::tick(); const int diff_ms = Time::diffMS(LogLastTick, cur); LogLastTick = cur; std::cout << " (took: " << diff_ms << "ms)" << std::endl; } private: static void addComp(const char* component) { std::cout << "[" << std::setw(12) << std::setfill(' ') << component << "] "; } }; #endif // DEBUG_H