refs #467 Only send a log message via DBus if it matches a pattern to which another process has subscribed.

This commit is contained in:
Mathew Sutcliffe
2015-09-21 02:13:51 +01:00
parent 3aa3a2a892
commit 1735ec9ff0
4 changed files with 22 additions and 2 deletions

View File

@@ -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);

View File

@@ -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;

View File

@@ -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)

View File

@@ -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)