diff options
author | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-05-12 17:01:25 +0200 |
---|---|---|
committer | Christian Mollekopf <chrigi_1@fastmail.fm> | 2017-05-12 17:18:18 +0200 |
commit | 58b9fa88198eecc224597e52d8bbd7f833fca63b (patch) | |
tree | 4d7b65992d699320398f947bfb134c54a69ecf8c /common/log.h | |
parent | 6a3bf46334fc4136da480287898d3f19c88261ee (diff) | |
download | sink-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.h | 5 |
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 | |||
89 | SINK_EXPORT bool isFiltered(DebugLevel debugLevel, const char *debugArea, const char *debugComponent, const char *file); | ||
90 | |||
88 | } | 91 | } |
89 | } | 92 | } |
90 | 93 | ||
91 | static const char *getComponentName() { return nullptr; } | 94 | static 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) |