diff options
author | Aaron Seigo <aseigo@kde.org> | 2016-01-10 11:19:34 +0100 |
---|---|---|
committer | Aaron Seigo <aseigo@kde.org> | 2016-01-10 11:20:31 +0100 |
commit | b3275b0e40c40dd20839c885a8b02f631f8032d0 (patch) | |
tree | b03c9be169ed0cb198c43e1f4cb1ef7444990f91 | |
parent | 2760d5944802f24321ed98083e9f15a484197f7b (diff) | |
download | sink-b3275b0e40c40dd20839c885a8b02f631f8032d0.tar.gz sink-b3275b0e40c40dd20839c885a8b02f631f8032d0.zip |
more helpers
-rw-r--r-- | common/log.cpp | 18 | ||||
-rw-r--r-- | common/log.h | 4 |
2 files changed, 16 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 | ||
99 | QByteArray debugLevelName(DebugLevel debugLevel) | 99 | QByteArray 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 | ||
117 | DebugLevel debugLevelFromName(const QByteArray &name) | 117 | DebugLevel 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 | ||
136 | Akonadi2::Log::DebugLevel Akonadi2::Log::debugOutputLevel() | ||
137 | { | ||
138 | return debugLevelFromName(qgetenv("AKONADI2DEBUGLEVEL")); | ||
139 | } | ||
140 | |||
135 | QDebug Akonadi2::Log::debugStream(DebugLevel debugLevel, int line, const char* file, const char* function, const char* debugArea) | 141 | QDebug 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")); |
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 { | |||
12 | Error | 12 | Error |
13 | }; | 13 | }; |
14 | 14 | ||
15 | QByteArray debugLevelName(DebugLevel debugLevel); | ||
16 | DebugLevel debugLevelFromName(const QByteArray &name); | ||
17 | |||
15 | void setDebugOutputLevel(DebugLevel); | 18 | void setDebugOutputLevel(DebugLevel); |
19 | DebugLevel debugOutputLevel(); | ||
16 | 20 | ||
17 | QDebug debugStream(DebugLevel debugLevel, int line, const char* file, const char* function, const char* debugArea = 0); | 21 | QDebug debugStream(DebugLevel debugLevel, int line, const char* file, const char* function, const char* debugArea = 0); |
18 | 22 | ||