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

View File

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