summaryrefslogtreecommitdiffstats
path: root/common/log.h
diff options
context:
space:
mode:
authorChristian Mollekopf <chrigi_1@fastmail.fm>2017-05-12 17:01:25 +0200
committerChristian Mollekopf <chrigi_1@fastmail.fm>2017-05-12 17:18:18 +0200
commit58b9fa88198eecc224597e52d8bbd7f833fca63b (patch)
tree4d7b65992d699320398f947bfb134c54a69ecf8c /common/log.h
parent6a3bf46334fc4136da480287898d3f19c88261ee (diff)
downloadsink-58b9fa88198eecc224597e52d8bbd7f833fca63b.tar.gz
sink-58b9fa88198eecc224597e52d8bbd7f833fca63b.zip
Completely shortcut the stream evaluation if we're not going to use the
output Serializing the data is the expensive part, so we want to completely avoid that for the noisier part if we're not going to use it. Additionally we're now using a stringbuilder for the debugarea to try to further improve the situation with temporary memory allocations.
Diffstat (limited to 'common/log.h')
-rw-r--r--common/log.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/common/log.h b/common/log.h
index be5a508..8266fdb 100644
--- a/common/log.h
+++ b/common/log.h
@@ -85,12 +85,15 @@ SINK_EXPORT inline QDebug operator<<(QDebug d, const TraceTime &time)
85 d << time.time << "[ms]"; 85 d << time.time << "[ms]";
86 return d; 86 return d;
87} 87}
88
89SINK_EXPORT bool isFiltered(DebugLevel debugLevel, const char *debugArea, const char *debugComponent, const char *file);
90
88} 91}
89} 92}
90 93
91static const char *getComponentName() { return nullptr; } 94static const char *getComponentName() { return nullptr; }
92 95
93#define SINK_DEBUG_STREAM_IMPL(LEVEL, AREA, COMPONENT) Sink::Log::debugStream(LEVEL, __LINE__, __FILE__, Q_FUNC_INFO, AREA, COMPONENT) 96#define SINK_DEBUG_STREAM_IMPL(LEVEL, AREA, COMPONENT) if (!Sink::Log::isFiltered(LEVEL, AREA, COMPONENT, __FILE__)) Sink::Log::debugStream(LEVEL, __LINE__, __FILE__, Q_FUNC_INFO, AREA, COMPONENT)
94 97
95#define Trace_area(AREA) SINK_DEBUG_STREAM_IMPL(Sink::Log::DebugLevel::Trace, AREA, nullptr) 98#define Trace_area(AREA) SINK_DEBUG_STREAM_IMPL(Sink::Log::DebugLevel::Trace, AREA, nullptr)
96#define Log_area(AREA) SINK_DEBUG_STREAM_IMPL(Sink::Log::DebugLevel::Log, AREA, nullptr) 99#define Log_area(AREA) SINK_DEBUG_STREAM_IMPL(Sink::Log::DebugLevel::Log, AREA, nullptr)