mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 16:41:02 +02:00
setup the repeated message flusher on LogHandler thread
This commit is contained in:
parent
9c485dc610
commit
5c5c69fff3
2 changed files with 9 additions and 1 deletions
|
@ -186,7 +186,7 @@ void LogHandler::verboseMessageHandler(QtMsgType type, const QMessageLogContext&
|
||||||
getInstance().printMessage((LogMsgType) type, context, message);
|
getInstance().printMessage((LogMsgType) type, context, message);
|
||||||
}
|
}
|
||||||
|
|
||||||
const QString& LogHandler::addRepeatedMessageRegex(const QString& regexString) {
|
void LogHandler::setupRepeatedMessageFlusher() {
|
||||||
static std::once_flag once;
|
static std::once_flag once;
|
||||||
std::call_once(once, [&] {
|
std::call_once(once, [&] {
|
||||||
// setup our timer to flush the verbose logs every 5 seconds
|
// setup our timer to flush the verbose logs every 5 seconds
|
||||||
|
@ -194,6 +194,11 @@ const QString& LogHandler::addRepeatedMessageRegex(const QString& regexString) {
|
||||||
connect(logFlushTimer, &QTimer::timeout, this, &LogHandler::flushRepeatedMessages);
|
connect(logFlushTimer, &QTimer::timeout, this, &LogHandler::flushRepeatedMessages);
|
||||||
logFlushTimer->start(VERBOSE_LOG_INTERVAL_SECONDS * 1000);
|
logFlushTimer->start(VERBOSE_LOG_INTERVAL_SECONDS * 1000);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
const QString& LogHandler::addRepeatedMessageRegex(const QString& regexString) {
|
||||||
|
// make sure we setup the repeated message flusher, but do it on the LogHandler thread
|
||||||
|
QMetaObject::invokeMethod(this, "setupRepeatedMessageFlusher");
|
||||||
|
|
||||||
QMutexLocker lock(&_mutex);
|
QMutexLocker lock(&_mutex);
|
||||||
return *_repeatedMessageRegexes.insert(regexString);
|
return *_repeatedMessageRegexes.insert(regexString);
|
||||||
|
|
|
@ -53,6 +53,9 @@ public:
|
||||||
const QString& addRepeatedMessageRegex(const QString& regexString);
|
const QString& addRepeatedMessageRegex(const QString& regexString);
|
||||||
const QString& addOnlyOnceMessageRegex(const QString& regexString);
|
const QString& addOnlyOnceMessageRegex(const QString& regexString);
|
||||||
|
|
||||||
|
private slots:
|
||||||
|
void setupRepeatedMessageFlusher();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
LogHandler();
|
LogHandler();
|
||||||
~LogHandler();
|
~LogHandler();
|
||||||
|
|
Loading…
Reference in a new issue