add logging engine

add options to control harris algorithum
This commit is contained in:
2020-10-27 20:59:19 +01:00
parent 6defcad11b
commit 38680f029c
7 changed files with 172 additions and 54 deletions

76
log.h Normal file
View File

@ -0,0 +1,76 @@
#pragma once
#include <iostream>
#include <string>
class Log
{
public:
enum Level
{
DEBUG,
INFO,
WARN,
ERROR
};
private:
bool opened = false;
Level msglevel = DEBUG;
inline std::string getLabel(Level level)
{
std::string label;
switch(level)
{
case DEBUG:
label = "DEBUG";
break;
case INFO:
label = "INFO ";
break;
case WARN:
label = "WARN ";
break;
case ERROR:
label = "ERROR";
break;
}
return label;
}
public:
inline static bool headers = false;
inline static Level level = WARN;
Log() {}
Log(Level type)
{
msglevel = type;
if(headers)
{
operator << ("["+getLabel(type)+"]");
}
}
~Log()
{
if(opened)
{
std::cout<<'\n';
}
opened = false;
}
template<class T> Log &operator<<(const T &msg)
{
if(msglevel >= level)
{
std::cout<<msg;
opened = true;
}
return *this;
}
};