[prev in list] [next in list] [prev in thread] [next in thread] 

List:       kde-commits
Subject:    [akonadi-next/feature/akonadish_log_control] common: more helpers
From:       Aaron Seigo <aseigo () kde ! org>
Date:       2016-01-10 10:25:55
Message-ID: E1aIDC7-0002IK-OI () scm ! kde ! org
[Download RAW message or body]

Git commit b3275b0e40c40dd20839c885a8b02f631f8032d0 by Aaron Seigo.
Committed on 10/01/2016 at 10:20.
Pushed by aseigo into branch 'feature/akonadish_log_control'.

more helpers

M  +12   -6    common/log.cpp
M  +4    -0    common/log.h

http://commits.kde.org/akonadi-next/b3275b0e40c40dd20839c885a8b02f631f8032d0

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<int> 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);  


[prev in list] [next in list] [prev in thread] [next in thread] 

Configure | About | News | Add a list | Sponsored by KoreLogic