mirror of
https://github.com/overte-org/overte.git
synced 2025-08-08 16:58:09 +02:00
always output the first matching repeated log message
This commit is contained in:
parent
424793b905
commit
c4538836c1
1 changed files with 21 additions and 10 deletions
|
@ -59,11 +59,14 @@ const char DATE_STRING_FORMAT[] = "%Y-%m-%d %H:%M:%S %z";
|
||||||
void LogHandler::flushRepeatedMessages() {
|
void LogHandler::flushRepeatedMessages() {
|
||||||
QHash<QString, int>::iterator message = _repeatMessageCountHash.begin();
|
QHash<QString, int>::iterator message = _repeatMessageCountHash.begin();
|
||||||
while (message != _repeatMessageCountHash.end()) {
|
while (message != _repeatMessageCountHash.end()) {
|
||||||
QString repeatMessage = QString("%1 repeated log entries matching \"%2\" - Last entry: \"%3\"")
|
|
||||||
.arg(message.value()).arg(message.key()).arg(_lastRepeatedMessage.value(message.key()));
|
|
||||||
|
|
||||||
QMessageLogContext emptyContext;
|
if (message.value() > 0) {
|
||||||
printMessage(LogSuppressed, emptyContext, repeatMessage);
|
QString repeatMessage = QString("%1 repeated log entries matching \"%2\" - Last entry: \"%3\"")
|
||||||
|
.arg(message.value()).arg(message.key()).arg(_lastRepeatedMessage.value(message.key()));
|
||||||
|
|
||||||
|
QMessageLogContext emptyContext;
|
||||||
|
printMessage(LogSuppressed, emptyContext, repeatMessage);
|
||||||
|
}
|
||||||
|
|
||||||
_lastRepeatedMessage.remove(message.key());
|
_lastRepeatedMessage.remove(message.key());
|
||||||
message = _repeatMessageCountHash.erase(message);
|
message = _repeatMessageCountHash.erase(message);
|
||||||
|
@ -82,12 +85,20 @@ QString LogHandler::printMessage(LogMsgType type, const QMessageLogContext& cont
|
||||||
QRegExp repeatRegex(regexString);
|
QRegExp repeatRegex(regexString);
|
||||||
if (repeatRegex.indexIn(message) != -1) {
|
if (repeatRegex.indexIn(message) != -1) {
|
||||||
|
|
||||||
// we have a match - add 1 to the count of repeats for this message and set this as the last repeated message
|
if (!_repeatMessageCountHash.contains(regexString)) {
|
||||||
_repeatMessageCountHash[regexString] += 1;
|
// we have a match but didn't have this yet - output the first one
|
||||||
_lastRepeatedMessage[regexString] = message;
|
_repeatMessageCountHash[regexString] = 0;
|
||||||
|
|
||||||
// return out, we're not printing this one
|
// break the foreach so we output the first match
|
||||||
return QString();
|
break;
|
||||||
|
} else {
|
||||||
|
// we have a match - add 1 to the count of repeats for this message and set this as the last repeated message
|
||||||
|
_repeatMessageCountHash[regexString] += 1;
|
||||||
|
_lastRepeatedMessage[regexString] = message;
|
||||||
|
|
||||||
|
// return out, we're not printing this one
|
||||||
|
return QString();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue