From e1716e503d96d4c8331fb1dc2e701f2b6df240ec Mon Sep 17 00:00:00 2001 From: Christian Mollekopf Date: Fri, 5 Feb 2016 11:59:30 +0100 Subject: Logging cleanup --- common/log.cpp | 18 ++++++++++-------- common/log.h | 21 ++++++++++++++------- 2 files changed, 24 insertions(+), 15 deletions(-) (limited to 'common') diff --git a/common/log.cpp b/common/log.cpp index ee28a3b..d2e5f47 100644 --- a/common/log.cpp +++ b/common/log.cpp @@ -142,17 +142,19 @@ Sink::Log::DebugLevel Sink::Log::debugOutputLevel() return debugLevelFromName(qgetenv("SINKDEBUGLEVEL")); } -void Sink::Log::setFilter(const QByteArrayList &filter) +void Sink::Log::setDebugOutputFilter(FilterType type, const QByteArrayList &filter) { - qputenv("SINKDEBUGFILTER", filter.join(',')); -} - -void Sink::Log::setAreas(const QByteArrayList &filter) -{ - qputenv("SINKDEBUGAREAS", filter.join(',')); + switch (type) { + case ApplicationName: + qputenv("SINKDEBUGFILTER", filter.join(',')); + break; + case Area: + qputenv("SINKDEBUGAREAS", filter.join(',')); + break; + } } -void Sink::Log::setDebugOutput(const QByteArrayList &output) +void Sink::Log::setDebugOutputFields(const QByteArrayList &output) { qputenv("SINKDEBUGOUTPUT", output.join(',')); } diff --git a/common/log.h b/common/log.h index 8a6c295..92d6cdd 100644 --- a/common/log.h +++ b/common/log.h @@ -24,25 +24,32 @@ DebugLevel SINKCOMMON_EXPORT debugLevelFromName(const QByteArray &name); void SINKCOMMON_EXPORT setDebugOutputLevel(DebugLevel); DebugLevel SINKCOMMON_EXPORT debugOutputLevel(); -/// Set debug areas that should be logged -void SINKCOMMON_EXPORT setAreas(const QByteArrayList &areas); +enum FilterType { + Area, + ApplicationName +}; /** - * Set an application name filter. + * Sets a debug output filter. + * + * Everything that is not matching the filter is ignored. + * An empty filter matches everything. * - * Note: In case of resources the identifier is the application name. + * Note: In case of resources the application name is the identifier. */ -void SINKCOMMON_EXPORT setFilter(const QByteArrayList &filter); +void SINKCOMMON_EXPORT setDebugOutputFilter(FilterType, const QByteArrayList &filter); /** - * Set an application debug output. + * Set the debug output fields. * * Currently supported are: * * Name: Application name used for filter. * * Function: The function name: * * Location: The source code location. + * + * These are additional items to the default ones (level, area, message). */ -void SINKCOMMON_EXPORT setDebugOutput(const QByteArrayList &filter); +void SINKCOMMON_EXPORT setDebugOutputFields(const QByteArrayList &filter); QDebug SINKCOMMON_EXPORT debugStream(DebugLevel debugLevel, int line, const char* file, const char* function, const char* debugArea = 0); -- cgit v1.2.3