added possebility to set debug level

This commit is contained in:
Patrick von Reth 2014-01-20 09:06:37 +01:00
parent f1dab6aa55
commit cdacc74d88
2 changed files with 13 additions and 12 deletions

View File

@ -21,22 +21,23 @@
#include <iostream>
using namespace Snore;
int Log::s_debugLevel = qgetenv("SNORE_DEBUG_LVL").toInt();
Log::Log(int lvl):
QDebug(&m_msg),
m_lvl(lvl)
QDebug(&m_msg),
m_lvl(lvl)
{
}
Log::~Log()
{
log();
if(debugLvl() >= m_lvl)
{
std::wcout << m_msg.toUtf8().constData() << std::endl;
}
}
void Log::log()
Log::setDebugLvl(int i)
{
if(debugLvl() >= m_lvl)
{
std::wcout << m_msg.toUtf8().constData() << std::endl;
}
s_debugLevel = i;
}

View File

@ -33,15 +33,15 @@ public:
static inline int debugLvl()
{
static int lvl = qgetenv("SNORE_DEBUG_LVL").toInt();
return lvl;
return s_debugLevel;
}
static setDebugLvl(int i);
private:
static int s_debugLevel;
int m_lvl;
QString m_msg;
void log();
};
}