From b3275b0e40c40dd20839c885a8b02f631f8032d0 Mon Sep 17 00:00:00 2001 From: Aaron Seigo Date: Sun, 10 Jan 2016 11:19:34 +0100 Subject: more helpers --- common/log.cpp | 18 ++++++++++++------ common/log.h | 4 ++++ 2 files changed, 16 insertions(+), 6 deletions(-) (limited to 'common') diff --git a/common/log.cpp b/common/log.cpp index c33c700..489e1bd 100644 --- a/common/log.cpp +++ b/common/log.cpp @@ -96,7 +96,7 @@ static QString colorCommand(QList colorCodes) return string; } -QByteArray debugLevelName(DebugLevel debugLevel) +QByteArray Akonadi2::Log::debugLevelName(DebugLevel debugLevel) { switch (debugLevel) { case DebugLevel::Trace: @@ -114,15 +114,16 @@ QByteArray debugLevelName(DebugLevel debugLevel) return QByteArray(); } -DebugLevel debugLevelFromName(const QByteArray &name) +DebugLevel Akonadi2::Log::debugLevelFromName(const QByteArray &name) { - if (name.toLower() == "trace") + const QByteArray lowercaseName = name.toLower(); + if (lowercaseName == "trace") return DebugLevel::Trace; - if (name.toLower() == "log") + if (lowercaseName == "log") return DebugLevel::Log; - if (name.toLower() == "warning") + if (lowercaseName == "warning") return DebugLevel::Warning; - if (name.toLower() == "error") + if (lowercaseName == "error") return DebugLevel::Error; return DebugLevel::Log; } @@ -132,6 +133,11 @@ void Akonadi2::Log::setDebugOutputLevel(DebugLevel debugLevel) qputenv("AKONADI2DEBUGLEVEL", debugLevelName(debugLevel)); } +Akonadi2::Log::DebugLevel Akonadi2::Log::debugOutputLevel() +{ + return debugLevelFromName(qgetenv("AKONADI2DEBUGLEVEL")); +} + QDebug Akonadi2::Log::debugStream(DebugLevel debugLevel, int line, const char* file, const char* function, const char* debugArea) { DebugLevel debugOutputLevel = debugLevelFromName(qgetenv("AKONADI2DEBUGLEVEL")); diff --git a/common/log.h b/common/log.h index 9db9e8e..e531348 100644 --- a/common/log.h +++ b/common/log.h @@ -12,7 +12,11 @@ enum DebugLevel { Error }; +QByteArray debugLevelName(DebugLevel debugLevel); +DebugLevel debugLevelFromName(const QByteArray &name); + void setDebugOutputLevel(DebugLevel); +DebugLevel debugOutputLevel(); QDebug debugStream(DebugLevel debugLevel, int line, const char* file, const char* function, const char* debugArea = 0); -- cgit v1.2.3