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
FrankE e6329e1db4 dijkstra is now bleching fast
deleting from the grid is now bleaching fast
added new helper methods
many new test-cases
many new methods for geo classes and others
added a bunch of new grid-walkers
2016-01-26 18:13:30 +01:00

54 lines
1.0 KiB
C++

#ifndef DEBUG_H
#define DEBUG_H
#include <string>
#include <iostream>
#include <iomanip>
#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