summaryrefslogtreecommitdiffstats
path: root/common/log.cpp
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2016-02-05 11:38:45 +0100
committerChristian Mollekopf <chrigi_1@fastmail.fm>2016-02-05 11:38:45 +0100
commite903e47cb0aada785e758264168d99bc4d0ad029 (patch)
tree4bde3e74fa3cd045be3a2eb13591588ab2acda5d /common/log.cpp
parentb16f3a02c8a4904f75f5c10ccc7eedac845cd940 (diff)
downloadsink-e903e47cb0aada785e758264168d99bc4d0ad029.tar.gz
sink-e903e47cb0aada785e758264168d99bc4d0ad029.zip
Set debug output
Diffstat (limited to 'common/log.cpp')
-rw-r--r--common/log.cpp23
1 files changed, 20 insertions, 3 deletions
diff --git a/common/log.cpp b/common/log.cpp
index 0f011b1..ee28a3b 100644
--- a/common/log.cpp
+++ b/common/log.cpp
@@ -152,6 +152,11 @@ void Sink::Log::setAreas(const QByteArrayList &filter)
152 qputenv("SINKDEBUGAREAS", filter.join(',')); 152 qputenv("SINKDEBUGAREAS", filter.join(','));
153} 153}
154 154
155void Sink::Log::setDebugOutput(const QByteArrayList &output)
156{
157 qputenv("SINKDEBUGOUTPUT", output.join(','));
158}
159
155static QByteArray getProgramName() 160static QByteArray getProgramName()
156{ 161{
157 if (QCoreApplication::instance()) { 162 if (QCoreApplication::instance()) {
@@ -171,6 +176,16 @@ static bool containsItemStartingWith(const QByteArray &pattern, const QByteArray
171 return false; 176 return false;
172} 177}
173 178
179static bool caseInsensitiveContains(const QByteArray &pattern, const QByteArrayList &list)
180{
181 for (const auto &item : list) {
182 if (item.toLower() == pattern) {
183 return true;
184 }
185 }
186 return false;
187}
188
174QDebug Sink::Log::debugStream(DebugLevel debugLevel, int line, const char* file, const char* function, const char* debugArea) 189QDebug Sink::Log::debugStream(DebugLevel debugLevel, int line, const char* file, const char* function, const char* debugArea)
175{ 190{
176 static NullStream nullstream; 191 static NullStream nullstream;
@@ -214,9 +229,11 @@ QDebug Sink::Log::debugStream(DebugLevel debugLevel, int line, const char* file,
214 break; 229 break;
215 }; 230 };
216 231
217 bool showLocation = false; 232 auto debugOutput = qgetenv("SINKDEBUGOUTPUT").split(',');
218 bool showFunction = false; 233
219 bool showProgram = false; 234 bool showLocation = debugOutput.isEmpty() ? false : caseInsensitiveContains("location", debugOutput);
235 bool showFunction = debugOutput.isEmpty() ? false : caseInsensitiveContains("function", debugOutput);
236 bool showProgram = debugOutput.isEmpty() ? false : caseInsensitiveContains("application", debugOutput);
220 bool useColor = true; 237 bool useColor = true;
221 bool multiline = false; 238 bool multiline = false;
222 239