some fixes [multithreading,..]
needed interface changes [new options] logger for android wifi-ap-optimization new test-cases
This commit is contained in:
40
misc/Debug.h
40
misc/Debug.h
@@ -6,6 +6,8 @@
|
||||
#include <iomanip>
|
||||
#include "Time.h"
|
||||
|
||||
#include "log/LoggerCOUT.h"
|
||||
|
||||
/** quick and dirty workaround */
|
||||
static decltype(Time::tick()) LogLastTick;
|
||||
|
||||
@@ -13,18 +15,36 @@ static decltype(Time::tick()) LogLastTick;
|
||||
|
||||
class Log {
|
||||
|
||||
private:
|
||||
|
||||
static Logger** getLoggerPtr() {
|
||||
static Logger* logger = new LoggerCOUT();
|
||||
return &logger;
|
||||
}
|
||||
|
||||
static Logger* getLogger() {
|
||||
return *getLoggerPtr();
|
||||
}
|
||||
|
||||
public:
|
||||
|
||||
/** set the to-be-used logger */
|
||||
static void setLogger(Logger* logger) {
|
||||
*getLoggerPtr() = logger;
|
||||
}
|
||||
|
||||
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;}
|
||||
std::stringstream out;
|
||||
addComp(out, comp);
|
||||
out << what;
|
||||
getLogger()->add(out.str(), nl);
|
||||
}
|
||||
|
||||
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;}
|
||||
std::stringstream out;
|
||||
addComp(out, component.c_str());
|
||||
out << what;
|
||||
getLogger()->add(out.str(), nl);
|
||||
}
|
||||
|
||||
|
||||
@@ -37,15 +57,17 @@ public:
|
||||
const auto cur = Time::tick();
|
||||
const int diff_ms = Time::diffMS(LogLastTick, cur);
|
||||
LogLastTick = cur;
|
||||
std::cout << " (took: " << diff_ms << "ms)" << std::endl;
|
||||
std::stringstream out;
|
||||
out << " (took: " << diff_ms << "ms)";
|
||||
getLogger()->add(out.str(), true);
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
|
||||
|
||||
static void addComp(const char* component) {
|
||||
std::cout << "[" << std::setw(12) << std::setfill(' ') << component << "] ";
|
||||
static void addComp(std::ostream& out, const char* component) {
|
||||
out << "[" << std::setw(12) << std::setfill(' ') << component << "] ";
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user