summaryrefslogtreecommitdiffstats
path: root/common/log.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'common/log.cpp')
-rw-r--r--common/log.cpp18
1 files changed, 12 insertions, 6 deletions
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)
96 return string; 96 return string;
97} 97}
98 98
99QByteArray debugLevelName(DebugLevel debugLevel) 99QByteArray Akonadi2::Log::debugLevelName(DebugLevel debugLevel)
100{ 100{
101 switch (debugLevel) { 101 switch (debugLevel) {
102 case DebugLevel::Trace: 102 case DebugLevel::Trace:
@@ -114,15 +114,16 @@ QByteArray debugLevelName(DebugLevel debugLevel)
114 return QByteArray(); 114 return QByteArray();
115} 115}
116 116
117DebugLevel debugLevelFromName(const QByteArray &name) 117DebugLevel Akonadi2::Log::debugLevelFromName(const QByteArray &name)
118{ 118{
119 if (name.toLower() == "trace") 119 const QByteArray lowercaseName = name.toLower();
120 if (lowercaseName == "trace")
120 return DebugLevel::Trace; 121 return DebugLevel::Trace;
121 if (name.toLower() == "log") 122 if (lowercaseName == "log")
122 return DebugLevel::Log; 123 return DebugLevel::Log;
123 if (name.toLower() == "warning") 124 if (lowercaseName == "warning")
124 return DebugLevel::Warning; 125 return DebugLevel::Warning;
125 if (name.toLower() == "error") 126 if (lowercaseName == "error")
126 return DebugLevel::Error; 127 return DebugLevel::Error;
127 return DebugLevel::Log; 128 return DebugLevel::Log;
128} 129}
@@ -132,6 +133,11 @@ void Akonadi2::Log::setDebugOutputLevel(DebugLevel debugLevel)
132 qputenv("AKONADI2DEBUGLEVEL", debugLevelName(debugLevel)); 133 qputenv("AKONADI2DEBUGLEVEL", debugLevelName(debugLevel));
133} 134}
134 135
136Akonadi2::Log::DebugLevel Akonadi2::Log::debugOutputLevel()
137{
138 return debugLevelFromName(qgetenv("AKONADI2DEBUGLEVEL"));
139}
140
135QDebug Akonadi2::Log::debugStream(DebugLevel debugLevel, int line, const char* file, const char* function, const char* debugArea) 141QDebug Akonadi2::Log::debugStream(DebugLevel debugLevel, int line, const char* file, const char* function, const char* debugArea)
136{ 142{
137 DebugLevel debugOutputLevel = debugLevelFromName(qgetenv("AKONADI2DEBUGLEVEL")); 143 DebugLevel debugOutputLevel = debugLevelFromName(qgetenv("AKONADI2DEBUGLEVEL"));