diff --git a/src/core/log.cpp b/src/core/log.cpp index 1bcd7cc..ebe168d 100644 --- a/src/core/log.cpp +++ b/src/core/log.cpp @@ -21,22 +21,23 @@ #include 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; } diff --git a/src/core/log.h b/src/core/log.h index 6eeb6ce..7cb4f2c 100644 --- a/src/core/log.h +++ b/src/core/log.h @@ -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(); }; }