This repository has been archived on 2020-04-08. You can view files and clone it, but cannot push or open issues or pull requests.
Files
Indoor/misc/Debug.h
kazu 9947dced15 added several grid-walks
added new helper methods/classes (e.g. for heading)
new test cases
optimize the dijkstra
cleanups/refactoring
added timed-benchmarks to the log
many more...
2016-01-24 18:59:06 +01:00

45 lines
772 B
C++

#ifndef DEBUG_H
#define DEBUG_H
#include <string>
#include <iostream>
#include <iomanip>
#include "Time.h"
class Log {
public:
static void add(const char* comp, const std::string what) {
addComp(comp);
std::cout << what;
addTime();
std::cout << std::endl;
}
static void add(const std::string& component, const std::string what) {
addComp(component.c_str());
std::cout << what;
addTime();
std::cout << std::endl;
}
private:
static void addTime() {
static auto last = Time::tick();
const auto cur = Time::tick();
std::cout << " (+" << Time::diffMS(last, cur) << "ms)";
last = cur;
}
static void addComp(const char* component) {
std::cout << "[" << std::setw(12) << std::setfill(' ') << component << "] ";
}
};
#endif // DEBUG_H