diff options
Diffstat (limited to 'common/log.cpp')
-rw-r--r-- | common/log.cpp | 45 |
1 files changed, 25 insertions, 20 deletions
diff --git a/common/log.cpp b/common/log.cpp index 83cdc8a..821df06 100644 --- a/common/log.cpp +++ b/common/log.cpp | |||
@@ -238,27 +238,34 @@ static bool caseInsensitiveContains(const QByteArray &pattern, const QByteArrayL | |||
238 | return false; | 238 | return false; |
239 | } | 239 | } |
240 | 240 | ||
241 | QDebug Sink::Log::debugStream(DebugLevel debugLevel, int line, const char *file, const char *function, const char *debugArea) | 241 | QDebug Sink::Log::debugStream(DebugLevel debugLevel, int line, const char *file, const char *function, const char *debugArea, const char *debugComponent) |
242 | { | 242 | { |
243 | static NullStream nullstream; | 243 | static NullStream nullstream; |
244 | if (debugLevel < debugOutputLevel()) { | 244 | if (debugLevel < debugOutputLevel()) { |
245 | return QDebug(&nullstream); | 245 | return QDebug(&nullstream); |
246 | } | 246 | } |
247 | 247 | ||
248 | auto areas = debugOutputFilter(Sink::Log::Area); | 248 | if (sPrimaryComponent.isEmpty()) { |
249 | if (debugArea && !areas.isEmpty()) { | 249 | sPrimaryComponent = getProgramName(); |
250 | if (!containsItemStartingWith(debugArea, areas)) { | ||
251 | return QDebug(&nullstream); | ||
252 | } | ||
253 | } | 250 | } |
254 | static QByteArray programName = getProgramName(); | 251 | QString fullDebugArea = sPrimaryComponent + "."+ QString::fromLatin1(debugComponent) + "." + QString::fromLatin1(debugArea); |
255 | 252 | ||
256 | auto filter = debugOutputFilter(Sink::Log::ApplicationName); | 253 | //TODO add to autocompletion |
257 | if (!filter.isEmpty() && !filter.contains(programName)) { | 254 | |
258 | if (!containsItemStartingWith(programName, filter)) { | 255 | auto areas = debugOutputFilter(Sink::Log::Area); |
256 | if (!areas.isEmpty()) { | ||
257 | if (!containsItemStartingWith(fullDebugArea.toUtf8(), areas)) { | ||
259 | return QDebug(&nullstream); | 258 | return QDebug(&nullstream); |
260 | } | 259 | } |
261 | } | 260 | } |
261 | // static QByteArray programName = getProgramName(); | ||
262 | // | ||
263 | // auto filter = debugOutputFilter(Sink::Log::ApplicationName); | ||
264 | // if (!filter.isEmpty() && !filter.contains(programName)) { | ||
265 | // if (!containsItemStartingWith(programName, filter)) { | ||
266 | // return QDebug(&nullstream); | ||
267 | // } | ||
268 | // } | ||
262 | 269 | ||
263 | QString prefix; | 270 | QString prefix; |
264 | int prefixColorCode = ANSI_Colors::DoNothing; | 271 | int prefixColorCode = ANSI_Colors::DoNothing; |
@@ -299,19 +306,17 @@ QDebug Sink::Log::debugStream(DebugLevel debugLevel, int line, const char *file, | |||
299 | } | 306 | } |
300 | if (showProgram) { | 307 | if (showProgram) { |
301 | int width = 10; | 308 | int width = 10; |
302 | output += QString(" %1(%2)").arg(QString::fromLatin1(programName).leftJustified(width, ' ', true)).arg(unsigned(getpid())).rightJustified(width + 8, ' '); | 309 | output += QString(" %1(%2)").arg(QString::fromLatin1(getProgramName()).leftJustified(width, ' ', true)).arg(unsigned(getpid())).rightJustified(width + 8, ' '); |
303 | } | 310 | } |
304 | if (debugArea) { | 311 | if (useColor) { |
305 | if (useColor) { | 312 | output += colorCommand(QList<int>() << ANSI_Colors::Bold << prefixColorCode); |
306 | output += colorCommand(QList<int>() << ANSI_Colors::Bold << prefixColorCode); | 313 | } |
307 | } | 314 | output += QString(" %1 ").arg(fullDebugArea.leftJustified(25, ' ', true)); |
308 | output += QString(" %1 ").arg(QString::fromLatin1(debugArea).leftJustified(25, ' ', true)); | 315 | if (useColor) { |
309 | if (useColor) { | 316 | output += resetColor; |
310 | output += resetColor; | ||
311 | } | ||
312 | } | 317 | } |
313 | if (showFunction) { | 318 | if (showFunction) { |
314 | output += QString(" %3").arg(QString::fromLatin1(function).leftJustified(25, ' ', true)); | 319 | output += QString(" %3").arg(fullDebugArea.leftJustified(25, ' ', true)); |
315 | } | 320 | } |
316 | if (showLocation) { | 321 | if (showLocation) { |
317 | const auto filename = QString::fromLatin1(file).split('/').last(); | 322 | const auto filename = QString::fromLatin1(file).split('/').last(); |