diff --git a/src/blackcore/context_application.cpp b/src/blackcore/context_application.cpp index 95221b70f..19f005fbc 100644 --- a/src/blackcore/context_application.cpp +++ b/src/blackcore/context_application.cpp @@ -111,6 +111,17 @@ namespace BlackCore CInputManager::instance()->setForwarding(true); } + CIdentifierList IContextApplication::subscribersOf(const CStatusMessage &message) const + { + CIdentifierList result; + for (auto it = m_logSubscriptions.begin(); it != m_logSubscriptions.end(); ++it) + { + bool match = std::any_of(it->begin(), it->end(), [&message](const CLogPattern &pattern) { return pattern.match(message); }); + if (match) { result.push_back(it.key()); } + } + return result; + } + void IContextApplication::changeSettings(const CVariantMap &settings, const CIdentifier &origin) { Q_UNUSED(settings); diff --git a/src/blackcore/context_application.h b/src/blackcore/context_application.h index 0778489e4..ac52078a5 100644 --- a/src/blackcore/context_application.h +++ b/src/blackcore/context_application.h @@ -109,6 +109,9 @@ namespace BlackCore void fakedSetComVoiceRoom(const BlackMisc::Audio::CVoiceRoomList &requestedRooms); protected: + //! Compute which process' subscriptions match a given log message. + BlackMisc::CIdentifierList subscribersOf(const BlackMisc::CStatusMessage &message) const; + //! Tracks which processes are subscribed to which patterns of log messages. CLogSubscriptionHash m_logSubscriptions; diff --git a/src/blackcore/context_application_impl.cpp b/src/blackcore/context_application_impl.cpp index edd1077d8..e555ec5bc 100644 --- a/src/blackcore/context_application_impl.cpp +++ b/src/blackcore/context_application_impl.cpp @@ -38,7 +38,10 @@ namespace BlackCore { CLogHandler::instance()->logRemoteMessage(message); } - emit this->messageLogged(message, origin); + if (subscribersOf(message).containsAnyNotIn(CIdentifierList({ origin, {} }))) + { + emit this->messageLogged(message, origin); + } } void CContextApplication::addLogSubscription(const CIdentifier &subscriber, const CLogPattern &pattern) diff --git a/src/blackcore/context_application_proxy.cpp b/src/blackcore/context_application_proxy.cpp index e553f93d5..30c6c8afc 100644 --- a/src/blackcore/context_application_proxy.cpp +++ b/src/blackcore/context_application_proxy.cpp @@ -65,7 +65,10 @@ namespace BlackCore void CContextApplicationProxy::logMessage(const CStatusMessage &message, const CIdentifier &origin) { - this->m_dBusInterface->callDBus(QLatin1Literal("logMessage"), message, origin); + if (subscribersOf(message).containsAnyNotIn(CIdentifierList({ origin, {} }))) + { + this->m_dBusInterface->callDBus(QLatin1Literal("logMessage"), message, origin); + } } void CContextApplicationProxy::addLogSubscription(const CIdentifier &subscriber, const CLogPattern &pattern)