Split log into h and cpp
This commit is contained in:
parent
4cb43c136f
commit
6b6c098529
3 changed files with 71 additions and 41 deletions
46
src/log.h
46
src/log.h
|
|
@ -37,51 +37,17 @@ 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;
|
||||
}
|
||||
std::string getLabel(Level level);
|
||||
|
||||
public:
|
||||
|
||||
|
||||
inline static bool headers = false;
|
||||
inline static Level level = WARN;
|
||||
static bool headers;
|
||||
static Level level;
|
||||
static bool endline;
|
||||
|
||||
Log() {}
|
||||
Log(Level type)
|
||||
{
|
||||
msglevel = type;
|
||||
if(headers)
|
||||
{
|
||||
operator << ("["+getLabel(type)+"]");
|
||||
}
|
||||
}
|
||||
|
||||
~Log()
|
||||
{
|
||||
if(opened)
|
||||
{
|
||||
std::cout<<'\n';
|
||||
}
|
||||
opened = false;
|
||||
}
|
||||
Log(Level type);
|
||||
~Log();
|
||||
|
||||
template<class T> Log &operator<<(const T &msg)
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue