mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-17 02:45:33 +08:00
refs #467 Mechanism for processes to notify each other of which log patterns they are subscribed to.
This commit is contained in:
@@ -9,6 +9,7 @@
|
|||||||
#include "voice_channel.h"
|
#include "voice_channel.h"
|
||||||
#include "network.h"
|
#include "network.h"
|
||||||
#include "simulator.h"
|
#include "simulator.h"
|
||||||
|
#include "context_application.h"
|
||||||
#include <QThread>
|
#include <QThread>
|
||||||
|
|
||||||
namespace BlackCore
|
namespace BlackCore
|
||||||
@@ -19,6 +20,8 @@ namespace BlackCore
|
|||||||
qRegisterMetaType<BlackCore::INetwork::ConnectionStatus>();
|
qRegisterMetaType<BlackCore::INetwork::ConnectionStatus>();
|
||||||
qRegisterMetaType<BlackCore::CWebReaderFlags::WebReaderFlag>();
|
qRegisterMetaType<BlackCore::CWebReaderFlags::WebReaderFlag>();
|
||||||
qRegisterMetaType<BlackCore::CWebReaderFlags::WebReader>();
|
qRegisterMetaType<BlackCore::CWebReaderFlags::WebReader>();
|
||||||
|
qDBusRegisterMetaType<BlackCore::CLogSubscriptionHash>();
|
||||||
|
qDBusRegisterMetaType<BlackCore::CLogSubscriptionPair>();
|
||||||
}
|
}
|
||||||
|
|
||||||
bool isCurrentThreadObjectThread(QObject *toBeTested)
|
bool isCurrentThreadObjectThread(QObject *toBeTested)
|
||||||
|
|||||||
@@ -48,6 +48,22 @@ namespace BlackCore
|
|||||||
{
|
{
|
||||||
this->logMessage(message, {});
|
this->logMessage(message, {});
|
||||||
});
|
});
|
||||||
|
connect(CLogHandler::instance(), &CLogHandler::subscriptionAdded, this, [this](const CLogPattern &pattern)
|
||||||
|
{
|
||||||
|
this->addLogSubscription({}, pattern);
|
||||||
|
});
|
||||||
|
connect(CLogHandler::instance(), &CLogHandler::subscriptionRemoved, this, [this](const CLogPattern &pattern)
|
||||||
|
{
|
||||||
|
this->removeLogSubscription({}, pattern);
|
||||||
|
});
|
||||||
|
connect(this, &IContextApplication::logSubscriptionAdded, this, [this](const CIdentifier &subscriber, const CLogPattern &pattern)
|
||||||
|
{
|
||||||
|
this->m_logSubscriptions[subscriber].push_back(pattern);
|
||||||
|
});
|
||||||
|
connect(this, &IContextApplication::logSubscriptionRemoved, this, [this](const CIdentifier &subscriber, const CLogPattern &pattern)
|
||||||
|
{
|
||||||
|
this->m_logSubscriptions[subscriber].removeAll(pattern);
|
||||||
|
});
|
||||||
|
|
||||||
connect(CSettingsCache::instance(), &CSettingsCache::valuesChangedByLocal, [this](const CVariantMap &settings)
|
connect(CSettingsCache::instance(), &CSettingsCache::valuesChangedByLocal, [this](const CVariantMap &settings)
|
||||||
{
|
{
|
||||||
@@ -122,3 +138,18 @@ namespace BlackCore
|
|||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
QDBusArgument &operator <<(QDBusArgument &arg, const BlackCore::CLogSubscriptionHash &hash)
|
||||||
|
{
|
||||||
|
QList<CLogSubscriptionPair> listOfPairs;
|
||||||
|
for (auto it = hash.begin(); it != hash.end(); ++it) { listOfPairs.push_back({ it.key(), it.value() }); }
|
||||||
|
return arg << listOfPairs;
|
||||||
|
}
|
||||||
|
|
||||||
|
const QDBusArgument &operator >>(const QDBusArgument &arg, BlackCore::CLogSubscriptionHash &hash)
|
||||||
|
{
|
||||||
|
QList<CLogSubscriptionPair> listOfPairs;
|
||||||
|
arg >> listOfPairs;
|
||||||
|
for (const auto &pair : listOfPairs) { hash.insert(pair.first, pair.second); }
|
||||||
|
return arg;
|
||||||
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@
|
|||||||
#include "blackmisc/audio/voiceroomlist.h"
|
#include "blackmisc/audio/voiceroomlist.h"
|
||||||
#include "blackmisc/identifierlist.h"
|
#include "blackmisc/identifierlist.h"
|
||||||
#include "blackmisc/variantmap.h"
|
#include "blackmisc/variantmap.h"
|
||||||
|
#include "blackmisc/logpattern.h"
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QReadWriteLock>
|
#include <QReadWriteLock>
|
||||||
|
|
||||||
@@ -36,6 +37,12 @@ namespace BlackCore
|
|||||||
{
|
{
|
||||||
class CInputManager;
|
class CInputManager;
|
||||||
|
|
||||||
|
//! Used by application context to track which processes are subscribed to which patterns of log message
|
||||||
|
using CLogSubscriptionHash = QHash<BlackMisc::CIdentifier, QList<BlackMisc::CLogPattern>>;
|
||||||
|
|
||||||
|
//! Used when marshalling CLogSubscriptionHash, as a QHash with CIdentifier keys can't be marshalled
|
||||||
|
using CLogSubscriptionPair = QPair<BlackMisc::CIdentifier, QList<BlackMisc::CLogPattern>>;
|
||||||
|
|
||||||
//! Application context interface
|
//! Application context interface
|
||||||
class BLACKCORE_EXPORT IContextApplication : public CContext
|
class BLACKCORE_EXPORT IContextApplication : public CContext
|
||||||
{
|
{
|
||||||
@@ -78,6 +85,14 @@ namespace BlackCore
|
|||||||
//! \note Used with CLogMessage, do not use directly
|
//! \note Used with CLogMessage, do not use directly
|
||||||
void messageLogged(const BlackMisc::CStatusMessage &message, const BlackMisc::CIdentifier &origin);
|
void messageLogged(const BlackMisc::CStatusMessage &message, const BlackMisc::CIdentifier &origin);
|
||||||
|
|
||||||
|
//! A process subscribed to a particular pattern of log messages
|
||||||
|
//! \note Used with CLogMessage, do not use directly
|
||||||
|
void logSubscriptionAdded(const BlackMisc::CIdentifier &subscriber, const BlackMisc::CLogPattern &pattern);
|
||||||
|
|
||||||
|
//! A process unsubscribed from a particular pattern of log messages
|
||||||
|
//! \note Used with CLogMessage, do not use directly
|
||||||
|
void logSubscriptionRemoved(const BlackMisc::CIdentifier &subscriber, const BlackMisc::CLogPattern &pattern);
|
||||||
|
|
||||||
//! One or more settings were changed
|
//! One or more settings were changed
|
||||||
//! \note Used for cache relay, do not use directly
|
//! \note Used for cache relay, do not use directly
|
||||||
void settingsChanged(const BlackMisc::CVariantMap &settings, const BlackMisc::CIdentifier &origin);
|
void settingsChanged(const BlackMisc::CVariantMap &settings, const BlackMisc::CIdentifier &origin);
|
||||||
@@ -93,12 +108,30 @@ namespace BlackCore
|
|||||||
//! Work around for audio context, #382
|
//! Work around for audio context, #382
|
||||||
void fakedSetComVoiceRoom(const BlackMisc::Audio::CVoiceRoomList &requestedRooms);
|
void fakedSetComVoiceRoom(const BlackMisc::Audio::CVoiceRoomList &requestedRooms);
|
||||||
|
|
||||||
|
protected:
|
||||||
|
//! Tracks which processes are subscribed to which patterns of log messages.
|
||||||
|
CLogSubscriptionHash m_logSubscriptions;
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
//! Log a log message
|
//! Log a log message
|
||||||
//! \note Not pure because it can be called from the base class constructor.
|
//! \note Not pure because it can be called from the base class constructor.
|
||||||
//! \note this is the function which relays CLogMessage via DBus
|
//! \note this is the function which relays CLogMessage via DBus
|
||||||
virtual void logMessage(const BlackMisc::CStatusMessage &message, const BlackMisc::CIdentifier &origin) { Q_UNUSED(message); Q_UNUSED(origin); }
|
virtual void logMessage(const BlackMisc::CStatusMessage &message, const BlackMisc::CIdentifier &origin) { Q_UNUSED(message); Q_UNUSED(origin); }
|
||||||
|
|
||||||
|
//! Subscribe a process to a particular pattern of log messages
|
||||||
|
//! \note This is the function which relays subscription changes via DBus
|
||||||
|
virtual void addLogSubscription(const BlackMisc::CIdentifier &subscriber, const BlackMisc::CLogPattern &pattern) = 0;
|
||||||
|
|
||||||
|
//! Unsubscribe a process from a particular pattern of log messages
|
||||||
|
//! \note This is the function which relays subscription changes via DBus
|
||||||
|
virtual void removeLogSubscription(const BlackMisc::CIdentifier &subscriber, const BlackMisc::CLogPattern &pattern) = 0;
|
||||||
|
|
||||||
|
//! Returns hash identifying which processes are subscribed to which patterns of log message
|
||||||
|
virtual BlackCore::CLogSubscriptionHash getAllLogSubscriptions() const = 0;
|
||||||
|
|
||||||
|
//! Update log subscriptions hash from core
|
||||||
|
virtual void synchronizeLogSubscriptions() = 0;
|
||||||
|
|
||||||
//! Ratify some settings changed by another process
|
//! Ratify some settings changed by another process
|
||||||
//! \note Not pure because it can be called from the base class constructor.
|
//! \note Not pure because it can be called from the base class constructor.
|
||||||
//! \note This is the function which relays cache changes via DBus.
|
//! \note This is the function which relays cache changes via DBus.
|
||||||
@@ -154,4 +187,13 @@ namespace BlackCore
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! DBus marshalling for CLogSubscriptionHash, needed because QtDBus can't marshal a QHash with CIdentifier keys.
|
||||||
|
QDBusArgument &operator <<(QDBusArgument &arg, const BlackCore::CLogSubscriptionHash &);
|
||||||
|
|
||||||
|
//! DBus unmarshalling for CLogSubscriptionHash, needed because QtDBus can't marshal a QHash with CIdentifier keys.
|
||||||
|
const QDBusArgument &operator >>(const QDBusArgument &arg, BlackCore::CLogSubscriptionHash &);
|
||||||
|
|
||||||
|
Q_DECLARE_METATYPE(BlackCore::CLogSubscriptionHash)
|
||||||
|
Q_DECLARE_METATYPE(BlackCore::CLogSubscriptionPair)
|
||||||
|
|
||||||
#endif // guard
|
#endif // guard
|
||||||
|
|||||||
@@ -41,6 +41,29 @@ namespace BlackCore
|
|||||||
emit this->messageLogged(message, origin);
|
emit this->messageLogged(message, origin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CContextApplication::addLogSubscription(const CIdentifier &subscriber, const CLogPattern &pattern)
|
||||||
|
{
|
||||||
|
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
||||||
|
emit this->logSubscriptionAdded(subscriber, pattern);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CContextApplication::removeLogSubscription(const CIdentifier &subscriber, const CLogPattern &pattern)
|
||||||
|
{
|
||||||
|
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
||||||
|
emit this->logSubscriptionRemoved(subscriber, pattern);
|
||||||
|
}
|
||||||
|
|
||||||
|
CLogSubscriptionHash CContextApplication::getAllLogSubscriptions() const
|
||||||
|
{
|
||||||
|
if (m_debugEnabled) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; }
|
||||||
|
return m_logSubscriptions;
|
||||||
|
}
|
||||||
|
|
||||||
|
void CContextApplication::synchronizeLogSubscriptions()
|
||||||
|
{
|
||||||
|
// no-op: proxy implements this method by calling getAllLogSubscriptions
|
||||||
|
}
|
||||||
|
|
||||||
void CContextApplication::changeSettings(const CVariantMap &settings, const CIdentifier &origin)
|
void CContextApplication::changeSettings(const CVariantMap &settings, const CIdentifier &origin)
|
||||||
{
|
{
|
||||||
// Intentionally don't check for round trip here
|
// Intentionally don't check for round trip here
|
||||||
|
|||||||
@@ -32,6 +32,18 @@ namespace BlackCore
|
|||||||
//! \copydoc IContextApplication::logMessage
|
//! \copydoc IContextApplication::logMessage
|
||||||
virtual void logMessage(const BlackMisc::CStatusMessage &message, const BlackMisc::CIdentifier &origin) override;
|
virtual void logMessage(const BlackMisc::CStatusMessage &message, const BlackMisc::CIdentifier &origin) override;
|
||||||
|
|
||||||
|
//! \copydoc IContextApplication::addLogSubscription
|
||||||
|
virtual void addLogSubscription(const BlackMisc::CIdentifier &subscriber, const BlackMisc::CLogPattern &pattern) override;
|
||||||
|
|
||||||
|
//! \copydoc IContextApplication::removeLogSubscription
|
||||||
|
virtual void removeLogSubscription(const BlackMisc::CIdentifier &subscriber, const BlackMisc::CLogPattern &pattern) override;
|
||||||
|
|
||||||
|
//! \copydoc IContextApplication::getAllLogSubscriptions
|
||||||
|
virtual CLogSubscriptionHash getAllLogSubscriptions() const;
|
||||||
|
|
||||||
|
//! \copydoc IContextApplication::synchronizeLogSubscriptions
|
||||||
|
virtual void synchronizeLogSubscriptions();
|
||||||
|
|
||||||
//! \copydoc IContextApplication::changeSettings
|
//! \copydoc IContextApplication::changeSettings
|
||||||
virtual void changeSettings(const BlackMisc::CVariantMap &settings, const BlackMisc::CIdentifier &origin) override;
|
virtual void changeSettings(const BlackMisc::CVariantMap &settings, const BlackMisc::CIdentifier &origin) override;
|
||||||
|
|
||||||
|
|||||||
@@ -43,6 +43,12 @@ namespace BlackCore
|
|||||||
bool s = connection.connect(serviceName, IContextApplication::ObjectPath(), IContextApplication::InterfaceName(),
|
bool s = connection.connect(serviceName, IContextApplication::ObjectPath(), IContextApplication::InterfaceName(),
|
||||||
"messageLogged", this, SIGNAL(messageLogged(BlackMisc::CStatusMessage, BlackMisc::CIdentifier)));
|
"messageLogged", this, SIGNAL(messageLogged(BlackMisc::CStatusMessage, BlackMisc::CIdentifier)));
|
||||||
Q_ASSERT(s);
|
Q_ASSERT(s);
|
||||||
|
s = connection.connect(serviceName, IContextApplication::ObjectPath(), IContextApplication::InterfaceName(),
|
||||||
|
"logSubscriptionAdded", this, SIGNAL(logSubscriptionAdded(BlackMisc::CIdentifier, BlackMisc::CLogPattern)));
|
||||||
|
Q_ASSERT(s);
|
||||||
|
s = connection.connect(serviceName, IContextApplication::ObjectPath(), IContextApplication::InterfaceName(),
|
||||||
|
"logSubscriptionRemoved", this, SIGNAL(logSubscriptionRemoved(BlackMisc::CIdentifier, BlackMisc::CLogPattern)));
|
||||||
|
Q_ASSERT(s);
|
||||||
s = connection.connect(serviceName, IContextApplication::ObjectPath(), IContextApplication::InterfaceName(),
|
s = connection.connect(serviceName, IContextApplication::ObjectPath(), IContextApplication::InterfaceName(),
|
||||||
"settingsChanged", this, SIGNAL(settingsChanged(BlackMisc::CVariantMap, BlackMisc::CIdentifier)));
|
"settingsChanged", this, SIGNAL(settingsChanged(BlackMisc::CVariantMap, BlackMisc::CIdentifier)));
|
||||||
Q_ASSERT(s);
|
Q_ASSERT(s);
|
||||||
@@ -62,6 +68,28 @@ namespace BlackCore
|
|||||||
this->m_dBusInterface->callDBus(QLatin1Literal("logMessage"), message, origin);
|
this->m_dBusInterface->callDBus(QLatin1Literal("logMessage"), message, origin);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void CContextApplicationProxy::addLogSubscription(const CIdentifier &subscriber, const CLogPattern &pattern)
|
||||||
|
{
|
||||||
|
this->m_dBusInterface->callDBus(QLatin1Literal("addLogSubscription"), subscriber, pattern);
|
||||||
|
}
|
||||||
|
|
||||||
|
void CContextApplicationProxy::removeLogSubscription(const CIdentifier &subscriber, const CLogPattern &pattern)
|
||||||
|
{
|
||||||
|
this->m_dBusInterface->callDBus(QLatin1Literal("removeLogSubscription"), subscriber, pattern);
|
||||||
|
}
|
||||||
|
|
||||||
|
CLogSubscriptionHash CContextApplicationProxy::getAllLogSubscriptions() const
|
||||||
|
{
|
||||||
|
return this->m_dBusInterface->callDBusRet<CLogSubscriptionHash>(QLatin1Literal("getAllLogSubscriptions"));
|
||||||
|
}
|
||||||
|
|
||||||
|
void CContextApplicationProxy::synchronizeLogSubscriptions()
|
||||||
|
{
|
||||||
|
// note this proxy method does not call synchronizeLogSubscriptions in core
|
||||||
|
m_logSubscriptions = getAllLogSubscriptions();
|
||||||
|
for (const auto &pattern : CLogHandler::instance()->getAllSubscriptions()) { this->addLogSubscription({}, pattern); }
|
||||||
|
}
|
||||||
|
|
||||||
void CContextApplicationProxy::changeSettings(const CVariantMap &settings, const CIdentifier &origin)
|
void CContextApplicationProxy::changeSettings(const CVariantMap &settings, const CIdentifier &origin)
|
||||||
{
|
{
|
||||||
this->m_dBusInterface->callDBus(QLatin1Literal("changeSettings"), settings, origin);
|
this->m_dBusInterface->callDBus(QLatin1Literal("changeSettings"), settings, origin);
|
||||||
|
|||||||
@@ -28,6 +28,18 @@ namespace BlackCore
|
|||||||
//! \copydoc IContextApplication::logMessage
|
//! \copydoc IContextApplication::logMessage
|
||||||
virtual void logMessage(const BlackMisc::CStatusMessage &message, const BlackMisc::CIdentifier &origin) override;
|
virtual void logMessage(const BlackMisc::CStatusMessage &message, const BlackMisc::CIdentifier &origin) override;
|
||||||
|
|
||||||
|
//! \copydoc IContextApplication::addLogSubscription
|
||||||
|
virtual void addLogSubscription(const BlackMisc::CIdentifier &subscriber, const BlackMisc::CLogPattern &pattern) override;
|
||||||
|
|
||||||
|
//! \copydoc IContextApplication::removeLogSubscription
|
||||||
|
virtual void removeLogSubscription(const BlackMisc::CIdentifier &subscriber, const BlackMisc::CLogPattern &pattern) override;
|
||||||
|
|
||||||
|
//! \copydoc IContextApplication::getAllLogSubscriptions
|
||||||
|
virtual CLogSubscriptionHash getAllLogSubscriptions() const;
|
||||||
|
|
||||||
|
//! \copydoc IContextApplication::synchronizeLogSubscriptions
|
||||||
|
virtual void synchronizeLogSubscriptions();
|
||||||
|
|
||||||
//! \copydoc IContextApplication::changeSettings
|
//! \copydoc IContextApplication::changeSettings
|
||||||
virtual void changeSettings(const BlackMisc::CVariantMap &settings, const BlackMisc::CIdentifier &origin) override;
|
virtual void changeSettings(const BlackMisc::CVariantMap &settings, const BlackMisc::CIdentifier &origin) override;
|
||||||
|
|
||||||
|
|||||||
@@ -24,6 +24,7 @@
|
|||||||
#include "pixmap.h"
|
#include "pixmap.h"
|
||||||
#include "iconlist.h"
|
#include "iconlist.h"
|
||||||
#include "identifierlist.h"
|
#include "identifierlist.h"
|
||||||
|
#include "logpattern.h"
|
||||||
#include <QtNetwork/QHostInfo>
|
#include <QtNetwork/QHostInfo>
|
||||||
#include <QProcessEnvironment>
|
#include <QProcessEnvironment>
|
||||||
#include <QSysInfo>
|
#include <QSysInfo>
|
||||||
@@ -83,6 +84,7 @@ void BlackMisc::registerMetadata()
|
|||||||
CIconList::registerMetadata();
|
CIconList::registerMetadata();
|
||||||
CLogCategory::registerMetadata();
|
CLogCategory::registerMetadata();
|
||||||
CLogCategoryList::registerMetadata();
|
CLogCategoryList::registerMetadata();
|
||||||
|
CLogPattern::registerMetadata();
|
||||||
CPixmap::registerMetadata();
|
CPixmap::registerMetadata();
|
||||||
CIdentifier::registerMetadata();
|
CIdentifier::registerMetadata();
|
||||||
CIdentifierList::registerMetadata();
|
CIdentifierList::registerMetadata();
|
||||||
|
|||||||
@@ -57,7 +57,7 @@ namespace BlackMisc
|
|||||||
auto it = std::find_if(m_patternHandlers.begin(), m_patternHandlers.end(), finder);
|
auto it = std::find_if(m_patternHandlers.begin(), m_patternHandlers.end(), finder);
|
||||||
if (it == m_patternHandlers.end())
|
if (it == m_patternHandlers.end())
|
||||||
{
|
{
|
||||||
auto *handler = new CLogPatternHandler(this);
|
auto *handler = new CLogPatternHandler(this, pattern);
|
||||||
topologicallySortedInsert(m_patternHandlers, PatternPair(pattern, handler), comparator);
|
topologicallySortedInsert(m_patternHandlers, PatternPair(pattern, handler), comparator);
|
||||||
return handler;
|
return handler;
|
||||||
}
|
}
|
||||||
@@ -149,8 +149,21 @@ namespace BlackMisc
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
CLogPatternHandler::CLogPatternHandler(CLogHandler *parent) :
|
QList<CLogPattern> CLogHandler::getAllSubscriptions() const
|
||||||
QObject(parent), m_parent(parent)
|
{
|
||||||
|
QList<CLogPattern> result;
|
||||||
|
for (const auto &pair : m_patternHandlers)
|
||||||
|
{
|
||||||
|
if (pair.second->isSignalConnected(QMetaMethod::fromSignal(&CLogPatternHandler::messageLogged)))
|
||||||
|
{
|
||||||
|
result.push_back(pair.first);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
CLogPatternHandler::CLogPatternHandler(CLogHandler *parent, const CLogPattern &pattern) :
|
||||||
|
QObject(parent), m_parent(parent), m_pattern(pattern)
|
||||||
{
|
{
|
||||||
connect(&m_subscriptionUpdateTimer, &QTimer::timeout, this, &CLogPatternHandler::updateSubscription);
|
connect(&m_subscriptionUpdateTimer, &QTimer::timeout, this, &CLogPatternHandler::updateSubscription);
|
||||||
m_subscriptionUpdateTimer.start(1);
|
m_subscriptionUpdateTimer.start(1);
|
||||||
@@ -163,7 +176,20 @@ namespace BlackMisc
|
|||||||
m_subscriptionNeedsUpdate = false;
|
m_subscriptionNeedsUpdate = false;
|
||||||
bool isSubscribed = isSignalConnected(QMetaMethod::fromSignal(&CLogPatternHandler::messageLogged));
|
bool isSubscribed = isSignalConnected(QMetaMethod::fromSignal(&CLogPatternHandler::messageLogged));
|
||||||
|
|
||||||
if (m_inheritFallThrough && ! isSubscribed)
|
if (isSubscribed != m_isSubscribed)
|
||||||
|
{
|
||||||
|
m_isSubscribed = isSubscribed;
|
||||||
|
if (m_isSubscribed)
|
||||||
|
{
|
||||||
|
emit m_parent->subscriptionAdded(m_pattern);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
emit m_parent->subscriptionRemoved(m_pattern);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (m_inheritFallThrough && ! m_isSubscribed)
|
||||||
{
|
{
|
||||||
m_parent->removePatternHandler(this);
|
m_parent->removePatternHandler(this);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -63,6 +63,9 @@ namespace BlackMisc
|
|||||||
return handlerForPattern(CLogPattern::exactMatch(CLogCategory::validation()).withSeverityAtOrAbove(CStatusMessage::SeverityWarning));
|
return handlerForPattern(CLogPattern::exactMatch(CLogCategory::validation()).withSeverityAtOrAbove(CStatusMessage::SeverityWarning));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//! Returns all log patterns for which there are currently subscribed log pattern handlers.
|
||||||
|
QList<CLogPattern> getAllSubscriptions() const;
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
//! Emitted when a message is logged in this process.
|
//! Emitted when a message is logged in this process.
|
||||||
void localMessageLogged(const BlackMisc::CStatusMessage &message);
|
void localMessageLogged(const BlackMisc::CStatusMessage &message);
|
||||||
@@ -70,6 +73,12 @@ namespace BlackMisc
|
|||||||
//! Emitted when a log message is relayed from a different process.
|
//! Emitted when a log message is relayed from a different process.
|
||||||
void remoteMessageLogged(const BlackMisc::CStatusMessage &message);
|
void remoteMessageLogged(const BlackMisc::CStatusMessage &message);
|
||||||
|
|
||||||
|
//! Emitted when an object subscribes to a pattern of log messages.
|
||||||
|
void subscriptionAdded(const BlackMisc::CLogPattern &pattern);
|
||||||
|
|
||||||
|
//! Emitted when an object unsubscribes from a pattern of log messages.
|
||||||
|
void subscriptionRemoved(const BlackMisc::CLogPattern &pattern);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
//! Called by our QtMessageHandler to log a message.
|
//! Called by our QtMessageHandler to log a message.
|
||||||
void logLocalMessage(const BlackMisc::CStatusMessage &message);
|
void logLocalMessage(const BlackMisc::CStatusMessage &message);
|
||||||
@@ -178,11 +187,13 @@ namespace BlackMisc
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
friend class CLogHandler;
|
friend class CLogHandler;
|
||||||
CLogPatternHandler(CLogHandler *parent);
|
CLogPatternHandler(CLogHandler *parent, const CLogPattern &pattern);
|
||||||
CLogHandler *m_parent = nullptr;
|
CLogHandler *m_parent = nullptr;
|
||||||
|
CLogPattern m_pattern;
|
||||||
bool m_inheritFallThrough = true;
|
bool m_inheritFallThrough = true;
|
||||||
bool m_enableFallThrough = true;
|
bool m_enableFallThrough = true;
|
||||||
std::atomic<bool> m_subscriptionNeedsUpdate = false;
|
bool m_isSubscribed = false;
|
||||||
|
std::atomic<bool> m_subscriptionNeedsUpdate { false };
|
||||||
QTimer m_subscriptionUpdateTimer;
|
QTimer m_subscriptionUpdateTimer;
|
||||||
void updateSubscription();
|
void updateSubscription();
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -319,6 +319,7 @@ void SwiftGuiStd::setContextAvailability()
|
|||||||
if (this->m_coreAvailable)
|
if (this->m_coreAvailable)
|
||||||
{
|
{
|
||||||
// core has just become available
|
// core has just become available
|
||||||
|
this->getIContextApplication()->synchronizeLogSubscriptions();
|
||||||
this->getIContextApplication()->synchronizeLocalSettings();
|
this->getIContextApplication()->synchronizeLocalSettings();
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|||||||
Reference in New Issue
Block a user