diff options
-rw-r--r-- | common/log.cpp | 8 | ||||
-rw-r--r-- | common/log.h | 8 |
2 files changed, 11 insertions, 5 deletions
diff --git a/common/log.cpp b/common/log.cpp index 1fbc482..e9e16c6 100644 --- a/common/log.cpp +++ b/common/log.cpp | |||
@@ -305,6 +305,12 @@ static bool caseInsensitiveContains(const QByteArray &pattern, const QByteArrayL | |||
305 | return false; | 305 | return false; |
306 | } | 306 | } |
307 | 307 | ||
308 | static QByteArray getFileName(const char *file) | ||
309 | { | ||
310 | auto filename = QByteArray(file).split('/').last(); | ||
311 | return filename.split('.').first(); | ||
312 | } | ||
313 | |||
308 | QDebug Sink::Log::debugStream(DebugLevel debugLevel, int line, const char *file, const char *function, const char *debugArea, const char *debugComponent) | 314 | QDebug Sink::Log::debugStream(DebugLevel debugLevel, int line, const char *file, const char *function, const char *debugArea, const char *debugComponent) |
309 | { | 315 | { |
310 | static NullStream nullstream; | 316 | static NullStream nullstream; |
@@ -315,7 +321,7 @@ QDebug Sink::Log::debugStream(DebugLevel debugLevel, int line, const char *file, | |||
315 | if (sPrimaryComponent.isEmpty()) { | 321 | if (sPrimaryComponent.isEmpty()) { |
316 | sPrimaryComponent = getProgramName(); | 322 | sPrimaryComponent = getProgramName(); |
317 | } | 323 | } |
318 | QString fullDebugArea = sPrimaryComponent + "." + (debugComponent ? (QString::fromLatin1(debugComponent) + ".") : "") + (debugArea ? QString::fromLatin1(debugArea) : ""); | 324 | QString fullDebugArea = sPrimaryComponent + "." + (debugComponent ? (QString::fromLatin1(debugComponent) + ".") : "") + (debugArea ? QString::fromLatin1(debugArea) : getFileName(file)); |
319 | 325 | ||
320 | collectDebugArea(fullDebugArea); | 326 | collectDebugArea(fullDebugArea); |
321 | 327 | ||
diff --git a/common/log.h b/common/log.h index 42193b7..be5a508 100644 --- a/common/log.h +++ b/common/log.h | |||
@@ -102,10 +102,10 @@ static const char *getComponentName() { return nullptr; } | |||
102 | #define SinkWarning_(COMPONENT, AREA) SINK_DEBUG_STREAM_IMPL(Sink::Log::DebugLevel::Warning, AREA, COMPONENT) | 102 | #define SinkWarning_(COMPONENT, AREA) SINK_DEBUG_STREAM_IMPL(Sink::Log::DebugLevel::Warning, AREA, COMPONENT) |
103 | #define SinkError_(COMPONENT, AREA) SINK_DEBUG_STREAM_IMPL(Sink::Log::DebugLevel::Error, AREA, COMPONENT) | 103 | #define SinkError_(COMPONENT, AREA) SINK_DEBUG_STREAM_IMPL(Sink::Log::DebugLevel::Error, AREA, COMPONENT) |
104 | 104 | ||
105 | #define SinkTrace() SINK_DEBUG_STREAM_IMPL(Sink::Log::DebugLevel::Trace, __FILE__, getComponentName()) | 105 | #define SinkTrace() SINK_DEBUG_STREAM_IMPL(Sink::Log::DebugLevel::Trace, nullptr, getComponentName()) |
106 | #define SinkLog() SINK_DEBUG_STREAM_IMPL(Sink::Log::DebugLevel::Log, __FILE__, getComponentName()) | 106 | #define SinkLog() SINK_DEBUG_STREAM_IMPL(Sink::Log::DebugLevel::Log, nullptr, getComponentName()) |
107 | #define SinkWarning() SINK_DEBUG_STREAM_IMPL(Sink::Log::DebugLevel::Warning, __FILE__, getComponentName()) | 107 | #define SinkWarning() SINK_DEBUG_STREAM_IMPL(Sink::Log::DebugLevel::Warning, nullptr, getComponentName()) |
108 | #define SinkError() SINK_DEBUG_STREAM_IMPL(Sink::Log::DebugLevel::Error, __FILE__, getComponentName()) | 108 | #define SinkError() SINK_DEBUG_STREAM_IMPL(Sink::Log::DebugLevel::Error, nullptr, getComponentName()) |
109 | 109 | ||
110 | #define SinkTraceCtx(CTX) SINK_DEBUG_STREAM_IMPL(Sink::Log::DebugLevel::Trace, CTX.name, nullptr) | 110 | #define SinkTraceCtx(CTX) SINK_DEBUG_STREAM_IMPL(Sink::Log::DebugLevel::Trace, CTX.name, nullptr) |
111 | #define SinkLogCtx(CTX) SINK_DEBUG_STREAM_IMPL(Sink::Log::DebugLevel::Log, CTX.name, nullptr) | 111 | #define SinkLogCtx(CTX) SINK_DEBUG_STREAM_IMPL(Sink::Log::DebugLevel::Log, CTX.name, nullptr) |