From e903e47cb0aada785e758264168d99bc4d0ad029 Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Fri, 5 Feb 2016 11:38:45 +0100 Subject: Set debug output --- common/log.cpp | 23 ++++++++++++++++++++--- 1 file changed, 20 insertions(+), 3 deletions(-) (limited to 'common/log.cpp') 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) qputenv("SINKDEBUGAREAS", filter.join(',')); } +void Sink::Log::setDebugOutput(const QByteArrayList &output) +{ + qputenv("SINKDEBUGOUTPUT", output.join(',')); +} + static QByteArray getProgramName() { if (QCoreApplication::instance()) { @@ -171,6 +176,16 @@ static bool containsItemStartingWith(const QByteArray &pattern, const QByteArray return false; } +static bool caseInsensitiveContains(const QByteArray &pattern, const QByteArrayList &list) +{ + for (const auto &item : list) { + if (item.toLower() == pattern) { + return true; + } + } + return false; +} + QDebug Sink::Log::debugStream(DebugLevel debugLevel, int line, const char* file, const char* function, const char* debugArea) { static NullStream nullstream; @@ -214,9 +229,11 @@ QDebug Sink::Log::debugStream(DebugLevel debugLevel, int line, const char* file, break; }; - bool showLocation = false; - bool showFunction = false; - bool showProgram = false; + auto debugOutput = qgetenv("SINKDEBUGOUTPUT").split(','); + + bool showLocation = debugOutput.isEmpty() ? false : caseInsensitiveContains("location", debugOutput); + bool showFunction = debugOutput.isEmpty() ? false : caseInsensitiveContains("function", debugOutput); + bool showProgram = debugOutput.isEmpty() ? false : caseInsensitiveContains("application", debugOutput); bool useColor = true; bool multiline = false; -- cgit v1.2.3