From b1c74d81e5feb753fcb45f3f15cbeb35cab73451 Mon Sep 17 00:00:00 2001 From: Mathew Sutcliffe Date: Thu, 25 Sep 2014 21:19:08 +0100 Subject: [PATCH] refs #316 Removed old logging mechanism in contexts. --- src/blackcore/context_application.cpp | 120 +-------- src/blackcore/context_application.h | 49 ---- src/blackcore/context_application_impl.h | 2 - src/blackcore/context_application_proxy.cpp | 3 - src/blackcore/context_audio_impl.h | 2 - src/blackcore/context_network_impl.h | 2 - src/blackcore/context_ownaircraft_impl.h | 2 - src/blackcore/context_runtime.cpp | 282 +------------------- src/blackcore/context_runtime.h | 180 ------------- src/blackcore/context_simulator_impl.h | 2 - src/swiftgui_standard/mainwindow.cpp | 7 - src/swiftgui_standard/mainwindow.h | 3 - src/swiftgui_standard/mainwindow_init.cpp | 1 - 13 files changed, 2 insertions(+), 653 deletions(-) diff --git a/src/blackcore/context_application.cpp b/src/blackcore/context_application.cpp index 970819297..3caf030e3 100644 --- a/src/blackcore/context_application.cpp +++ b/src/blackcore/context_application.cpp @@ -13,7 +13,6 @@ using namespace BlackMisc::Settings; namespace BlackCore { - QList IContextApplication::s_contexts; QtMessageHandler IContextApplication::s_oldHandler = nullptr; IContextApplication *IContextApplication::create(CRuntime *parent, CRuntimeConfig::ContextMode mode, CDBusServer *server, QDBusConnection &conn) @@ -31,29 +30,11 @@ namespace BlackCore } } - IContextApplication::RedirectionLevel IContextApplication::getOutputRedirectionLevel() const - { - QReadLocker(&this->m_lock); - return this->m_outputRedirectionLevel; - } - - void IContextApplication::setOutputRedirectionLevel(IContextApplication::RedirectionLevel redirectionLevel) - { - QWriteLocker(&this->m_lock); - this->m_outputRedirectionLevel = redirectionLevel; - } - - IContextApplication::RedirectionLevel IContextApplication::getStreamingForRedirectedOutputLevel() const - { - QReadLocker(&this->m_lock); - return this->m_redirectedOutputRedirectionLevel; - } - /* * Constructor */ IContextApplication::IContextApplication(CRuntimeConfig::ContextMode mode, CRuntime *runtime) : - CContext(mode, runtime), m_outputRedirectionLevel(IContextApplication::RedirectNone), m_redirectedOutputRedirectionLevel(IContextApplication::RedirectNone) + CContext(mode, runtime) { if (IContextApplication::s_contexts.isEmpty()) { @@ -64,28 +45,6 @@ namespace BlackCore changeSettings(IContextSettings::SettingsHotKeys); } - /* - * Output data from redirect signal - */ - void IContextApplication::setStreamingForRedirectedOutputLevel(RedirectionLevel redirectionLevel) - { - QWriteLocker(&this->m_lock); - disconnect(this, &IContextApplication::redirectedOutput, this, &IContextApplication::streamRedirectedOutput); - if (redirectionLevel != RedirectNone) - { - connect(this, &IContextApplication::redirectedOutput, this, &IContextApplication::streamRedirectedOutput); - } - this->m_redirectedOutputRedirectionLevel = redirectionLevel; - } - - /* - * Reset output redirection - */ - void IContextApplication::resetOutputRedirection() - { - qInstallMessageHandler(0); - } - void IContextApplication::changeSettings(uint typeValue) { auto type = static_cast(typeValue); @@ -107,83 +66,6 @@ namespace BlackCore */ void IContextApplication::messageHandlerDispatch(QtMsgType type, const QMessageLogContext &messageContext, const QString &message) { - if (IContextApplication::s_oldHandler) IContextApplication::s_oldHandler(type, messageContext, message); - if (IContextApplication::s_contexts.isEmpty()) return; - foreach(IContextApplication *ctx, IContextApplication::s_contexts) - { - ctx->messageHandler(type, messageContext, message); - } } - /* - * Handle message - */ - void IContextApplication::messageHandler(QtMsgType type, const QMessageLogContext &messageContext, const QString &message) - { - Q_UNUSED(messageContext); - RedirectionLevel outputRedirectionLevel = this->getOutputRedirectionLevel(); // local copy, thready safety - if (outputRedirectionLevel == RedirectNone) return; - CStatusMessage m(CStatusMessage::TypeStdoutRedirect, CStatusMessage::SeverityInfo, message); - switch (type) - { - case QtDebugMsg: - if (outputRedirectionLevel != RedirectAllOutput) return; - break; - case QtWarningMsg: - if (outputRedirectionLevel == RedirectAllOutput) return; - if (outputRedirectionLevel == RedirectError) return; - m.setSeverity(CStatusMessage::SeverityWarning); - break; - case QtCriticalMsg: - if (outputRedirectionLevel != RedirectError) return; - m.setSeverity(CStatusMessage::SeverityError); - break; - case QtFatalMsg: - if (m_outputRedirectionLevel != RedirectError) return; - m.setSeverity(CStatusMessage::SeverityError); - break; - default: - break; - } - - // emit signal, based on thread id - if (QThread::currentThread() == this->thread()) - { - // same thread, can emit directly - emit this->redirectedOutput(m, this->getUniqueId()); - } - else - { - // Different threads, use invoke so that is called in "main / object's thread" - // Otherwise for DBus: QtDBus: cannot relay signals from parent BlackCore::CContextApplication(0x4b4358 "") unless they are emitted in the object's thread QThread(0x4740b0 ""). Current thread is QThread(0x4b5530 "Thread (pooled)") - QMetaObject::invokeMethod(this, "redirectedOutput", Q_ARG(BlackMisc::CStatusMessage, m), Q_ARG(qint64, this->getUniqueId())); - } - } - - /* - * Redirected output - */ - void IContextApplication::streamRedirectedOutput(const CStatusMessage &message, qint64 contextId) - { - if (this->getUniqueId() == contextId) return; // avoid infinite output - RedirectionLevel redirectedOutputRedirectionLevel = this->getStreamingForRedirectedOutputLevel(); // local copy - - if (message.isEmpty()) return; - switch (message.getSeverity()) - { - case CStatusMessage::SeverityInfo: - if (redirectedOutputRedirectionLevel != RedirectAllOutput) return; - qDebug() << message.getMessage(); - break; - case CStatusMessage::SeverityWarning: - if (redirectedOutputRedirectionLevel == RedirectAllOutput) return; - if (redirectedOutputRedirectionLevel == RedirectError) return; - qWarning() << message.getMessage(); - break; - case CStatusMessage::SeverityError: - if (redirectedOutputRedirectionLevel != RedirectError) return; - qCritical() << message.getMessage(); - break; - } - } } // namespace diff --git a/src/blackcore/context_application.h b/src/blackcore/context_application.h index 567f27410..2f80286ea 100644 --- a/src/blackcore/context_application.h +++ b/src/blackcore/context_application.h @@ -42,16 +42,6 @@ namespace BlackCore IContextApplication(CRuntimeConfig::ContextMode mode, CRuntime *runtime); public: - - //! What output to redirect - enum RedirectionLevel : uint - { - RedirectNone, - RedirectAllOutput, - RedirectWarningAndAbove, - RedirectError - }; - //! Components enum Component : uint { @@ -92,25 +82,6 @@ namespace BlackCore //! Destructor virtual ~IContextApplication() {} - //! Output redirection (redirect my output) - //! \threadsafe - RedirectionLevel getOutputRedirectionLevel() const; - - //! Output redirection (redirect my output) - //! \threadsafe - void setOutputRedirectionLevel(RedirectionLevel redirectionLevel); - - //! Redirected output generated by others - //! \threadsafe - RedirectionLevel getStreamingForRedirectedOutputLevel() const; - - //! Redirected output generated by others - //! \threadsafe - void setStreamingForRedirectedOutputLevel(RedirectionLevel redirectionLevel) ; - - //! Reset output redirection - static void resetOutputRedirection(); - signals: //! \brief Status message //! \remarks not to be called directly, use IContextApplication::sendStatusMessage @@ -120,11 +91,6 @@ namespace BlackCore //! \remarks not to be called directly, use IContextApplication::sendStatusMessage(s) void statusMessages(const BlackMisc::CStatusMessageList &messages); - //! Redirect output streams as by qDebug(), qWarning(), qCritical() - //! \remarks context id is an important means to avoid infinite redirect loops - //! never output redirected stream messages from the same context again - void redirectedOutput(const BlackMisc::CStatusMessage &message, qint64 contextId); - //! A component changes void componentChanged(uint component, uint action); @@ -161,28 +127,13 @@ namespace BlackCore void changeSettings(uint typeValue); private: - //! All contexts, used with messageHandler - static QList s_contexts; - //! Previous message handler static QtMessageHandler s_oldHandler; - //! Message handler, handles one individual context - //! \threadsafe - void messageHandler(QtMsgType type, const QMessageLogContext &messageContext, const QString &messsage); - //! Handle output dispatch, handles all contexts //! \threadsafe static void messageHandlerDispatch(QtMsgType type, const QMessageLogContext &messageContext, const QString &message); - - RedirectionLevel m_outputRedirectionLevel; //!< enable / disable my output - RedirectionLevel m_redirectedOutputRedirectionLevel; //!< enable / disable others' output mutable QReadWriteLock m_lock; //!< thread safety - - private slots: - //! Re-stream the redirected output - void streamRedirectedOutput(const BlackMisc::CStatusMessage &message, qint64 contextId); - }; } diff --git a/src/blackcore/context_application_impl.h b/src/blackcore/context_application_impl.h index 2df32ea74..11099891f 100644 --- a/src/blackcore/context_application_impl.h +++ b/src/blackcore/context_application_impl.h @@ -53,8 +53,6 @@ namespace BlackCore virtual void processHotkeyFuncEvent(const BlackMisc::Event::CEventHotkeyFunction &event) override; protected: - static const auto c_logContext = CRuntime::LogForApplication; //!< identifier - //! Constructor CContextApplication(CRuntimeConfig::ContextMode mode, CRuntime *runtime); diff --git a/src/blackcore/context_application_proxy.cpp b/src/blackcore/context_application_proxy.cpp index 6eae14218..6df5f22f1 100644 --- a/src/blackcore/context_application_proxy.cpp +++ b/src/blackcore/context_application_proxy.cpp @@ -39,9 +39,6 @@ namespace BlackCore s = connection.connect(serviceName, IContextApplication::ObjectPath(), IContextApplication::InterfaceName(), "statusMessages", this, SIGNAL(statusMessages(BlackMisc::CStatusMessageList))); Q_ASSERT(s); - s = connection.connect(serviceName, IContextApplication::ObjectPath(), IContextApplication::InterfaceName(), - "redirectedOutput", this, SIGNAL(redirectedOutput(BlackMisc::CStatusMessage, qint64))); - Q_ASSERT(s); s = connection.connect(serviceName, IContextApplication::ObjectPath(), IContextApplication::InterfaceName(), "componentChanged", this, SIGNAL(componentChanged(uint, uint))); Q_ASSERT(s); diff --git a/src/blackcore/context_audio_impl.h b/src/blackcore/context_audio_impl.h index e642a9d1e..c7f12c59b 100644 --- a/src/blackcore/context_audio_impl.h +++ b/src/blackcore/context_audio_impl.h @@ -131,8 +131,6 @@ namespace BlackCore void ps_initNotificationSounds(); private: - static const auto c_logContext = CRuntime::LogForAudio; - //! Connection in transition bool inTransitionState() const; diff --git a/src/blackcore/context_network_impl.h b/src/blackcore/context_network_impl.h index c85f90e66..23a37cb02 100644 --- a/src/blackcore/context_network_impl.h +++ b/src/blackcore/context_network_impl.h @@ -148,8 +148,6 @@ namespace BlackCore } private: - static const auto c_logContext = CRuntime::LogForNetwork; - CAirspaceMonitor *m_airspace; BlackCore::INetwork *m_network; INetwork::ConnectionStatus m_currentStatus; //!< used to detect pending connections diff --git a/src/blackcore/context_ownaircraft_impl.h b/src/blackcore/context_ownaircraft_impl.h index d853b7118..e0267c67e 100644 --- a/src/blackcore/context_ownaircraft_impl.h +++ b/src/blackcore/context_ownaircraft_impl.h @@ -79,8 +79,6 @@ namespace BlackCore void ps_changedAtcStationOnlineConnectionStatus(const BlackMisc::Aviation::CAtcStation &atcStation, bool connected); private: - static const auto c_logContext = CRuntime::LogForOwnAircraft; - BlackMisc::Aviation::CAircraft m_ownAircraft; //!< my aircraft bool m_automaticVoiceRoomResolution; //!< voice room override QString m_voiceRoom1UrlOverride; //!< overridden voice room url diff --git a/src/blackcore/context_runtime.cpp b/src/blackcore/context_runtime.cpp index c90a8f543..1741beac9 100644 --- a/src/blackcore/context_runtime.cpp +++ b/src/blackcore/context_runtime.cpp @@ -20,278 +20,12 @@ namespace BlackCore */ CRuntime::CRuntime(const CRuntimeConfig &config, QObject *parent) : QObject(parent), m_init(false), m_dbusServer(nullptr), m_initDBusConnection(false), - m_signalLogApplication(false), m_signalLogAudio(false), m_signalLogNetwork(false), m_signalLogOwnAircraft(false), m_signalLogSettings(false), m_signalLogSimulator(false), - m_slotLogApplication(false), m_slotLogAudio(false), m_slotLogNetwork(false), m_slotLogOwnAircraft(false), m_slotLogSettings(false), m_slotLogSimulator(false), m_dbusConnection(QDBusConnection("default")), m_contextApplication(nullptr), m_contextAudio(nullptr), m_contextNetwork(nullptr), m_contextSettings(nullptr), m_contextSimulator(nullptr) { this->init(config); } - /* - * Signal logging - */ - void CRuntime::signalLog(bool enabled) - { - this->signalLogForApplication(enabled); - this->signalLogForAudio(enabled); - this->signalLogForNetwork(enabled); - this->signalLogForOwnAircraft(enabled); - this->signalLogForSettings(enabled); - this->signalLogForSimulator(enabled); - } - - /* - * Signal logging - */ - void CRuntime::slotLog(bool enabled) - { - this->slotLogForApplication(enabled); - this->slotLogForAudio(enabled); - this->slotLogForNetwork(enabled); - this->slotLogForOwnAircraft(enabled); - this->slotLogForSettings(enabled); - this->slotLogForSimulator(enabled); - } - - /* - * Enable signal logging - */ - bool CRuntime::signalLogForApplication(bool enabled) - { - QWriteLocker wl(&m_lock); - if (enabled == this->m_signalLogApplication) return enabled; - if (!this->getIContextApplication()) - { - this->m_signalLogApplication = false; - return false; - } - this->m_signalLogApplication = enabled; - if (enabled) - { - // connect signal / slots when enabled - QMetaObject::Connection con; - con = QObject::connect(this->getIContextApplication(), &IContextApplication::componentChanged, - [this](uint component, uint action) { QStringList l; l << "componentChanged" << QString::number(component) << QString::number(action); this->logSignal(this->getIContextApplication(), l);}); - this->m_logSignalConnections.insert("application", con); - con = QObject::connect(this->getIContextApplication(), &IContextApplication::statusMessage, - [this](const BlackMisc::CStatusMessage & msg) { QStringList l; l << "statusMessage" << msg.toQString() ; this->logSignal(this->getIContextApplication(), l);}); - this->m_logSignalConnections.insert("application", con); - con = QObject::connect(this->getIContextApplication(), &IContextApplication::statusMessages, - [this](const BlackMisc::CStatusMessageList & msgs) { QStringList l; l << "statusMessages" << msgs.toQString(); this->logSignal(this->getIContextApplication(), l);}); - this->m_logSignalConnections.insert("application", con); - } - else - { - this->disconnectLogSignals("application"); - } - return enabled; - } - - bool CRuntime::signalLogForAudio(bool enabled) - { - QWriteLocker wl(&m_lock); - if (enabled == this->m_signalLogAudio) return enabled; - if (!this->getIContextNetwork()) - { - this->m_signalLogAudio = false; - return false; - } - this->m_signalLogAudio = enabled; - if (enabled) - { - QMetaObject::Connection con; - con = QObject::connect(this->getIContextAudio(), &IContextAudio::audioTestCompleted, - [this]() { QStringList l; l << "audioTestCompleted"; this->logSignal(this->getIContextAudio(), l);}); - this->m_logSignalConnections.insert("audio", con); - } - else - { - this->disconnectLogSignals("audio"); - } - return enabled; - } - - /* - * Enable signal logging - */ - bool CRuntime::signalLogForNetwork(bool enabled) - { - QWriteLocker wl(&m_lock); - if (enabled == this->m_signalLogNetwork) return enabled; - if (!this->getIContextNetwork()) - { - this->m_signalLogNetwork = false; - return false; - } - this->m_signalLogNetwork = enabled; - if (enabled) - { - QMetaObject::Connection con; - con = QObject::connect(this->getIContextNetwork(), &IContextNetwork::changedAircraftsInRange, - [this]() { QStringList l; l << "changedAircraftsInRange"; this->logSignal(this->getIContextNetwork(), l);}); - this->m_logSignalConnections.insert("network", con); - con = QObject::connect(this->getIContextNetwork(), &IContextNetwork::changedAtcStationsBooked, - [this]() { QStringList l; l << "changedAtcStationsBooked"; this->logSignal(this->getIContextNetwork(), l);}); - this->m_logSignalConnections.insert("network", con); - con = QObject::connect(this->getIContextNetwork(), &IContextNetwork::changedAtcStationsOnline, - [this]() { QStringList l; l << "changedAtcStationsOnline"; this->logSignal(this->getIContextNetwork(), l);}); - this->m_logSignalConnections.insert("network", con); - con = QObject::connect(this->getIContextNetwork(), &IContextNetwork::changedAircraftSituation, - [this](const BlackMisc::Aviation::CCallsign & callsign, const BlackMisc::Aviation::CAircraftSituation & situation) { QStringList l; l << "changedAircraftSituation" << callsign.toQString() << situation.toQString(); this->logSignal(this->getIContextNetwork(), l);}); - this->m_logSignalConnections.insert("network", con); - con = QObject::connect(this->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, - [this](uint from, uint to) { QStringList l; l << "connectionStatusChanged" << QString::number(from) << QString::number(to); this->logSignal(this->getIContextNetwork(), l);}); - this->m_logSignalConnections.insert("network", con); - } - else - { - this->disconnectLogSignals("network"); - } - return enabled; - } - - /* - * Enable signal logging - */ - bool CRuntime::signalLogForOwnAircraft(bool enabled) - { - QWriteLocker wl(&m_lock); - if (enabled == this->m_signalLogOwnAircraft) return enabled; - if (!this->getIContextOwnAircraft()) - { - this->m_signalLogOwnAircraft = false; - return false; - } - this->m_signalLogOwnAircraft = enabled; - if (enabled) - { - // connect signal / slots when enabled - QMetaObject::Connection con; - con = QObject::connect(this->getIContextOwnAircraft(), &IContextOwnAircraft::changedAircraftSituation, - [this](const BlackMisc::Aviation::CAircraft & aircraft, const QString & originator) { QStringList l; l << "changedAircraftSituation" << aircraft.toQString() << originator; this->logSignal(this->getIContextOwnAircraft(), l);}); - this->m_logSignalConnections.insert("ownaircraft", con); - - con = QObject::connect(this->getIContextOwnAircraft(), &IContextOwnAircraft::changedAircraftCockpit, - [this](const BlackMisc::Aviation::CAircraft & aircraft, const QString & originator) { QStringList l; l << "changedAircraftCockpit" << aircraft.toQString() << originator; this->logSignal(this->getIContextOwnAircraft(), l);}); - this->m_logSignalConnections.insert("ownaircraft", con); - - con = QObject::connect(this->getIContextOwnAircraft(), &IContextOwnAircraft::changedAircraftPosition, - [this](const BlackMisc::Aviation::CAircraft & aircraft, const QString & originator) { QStringList l; l << "changedAircraftPosition" << aircraft.toQString() << originator; this->logSignal(this->getIContextOwnAircraft(), l);}); - this->m_logSignalConnections.insert("ownaircraft", con); - } - else - { - this->disconnectLogSignals("ownaircraft"); - } - return enabled; - } - - - /* - * Enable signal logging - */ - bool CRuntime::signalLogForSettings(bool enabled) - { - QWriteLocker wl(&m_lock); - if (enabled == this->m_signalLogSettings) return enabled; - if (!this->getIContextSettings()) - { - this->m_signalLogSettings = false; - return false; - } - this->m_signalLogSettings = enabled; - if (enabled) - { - QMetaObject::Connection con; - con = QObject::connect(this->getIContextSettings(), &IContextSettings::changedSettings, - [this]() { QStringList l; l << "changedSettings"; this->logSignal(this->getIContextSettings(), l);}); - this->m_logSignalConnections.insert("settings", con); - } - else - { - this->disconnectLogSignals("settings"); - } - return enabled; - } - - /* - * Enable signal logging - */ - bool CRuntime::signalLogForSimulator(bool enabled) - { - QWriteLocker wl(&m_lock); - if (enabled == this->m_signalLogSimulator) return enabled; - if (!this->getIContextSimulator()) - { - this->m_signalLogSimulator = false; - return false; - } - this->m_signalLogSimulator = enabled; - if (enabled) - { - QMetaObject::Connection con; - con = QObject::connect(this->getIContextSimulator(), &IContextSimulator::connectionChanged, - [this]() { QStringList l; l << "connectionChanged"; this->logSignal(this->getIContextSimulator(), l);}); - this->m_logSignalConnections.insert("simulator", con); - } - else - { - this->disconnectLogSignals("simulator"); - } - return enabled; - } - - void CRuntime::logSignal(QObject *sender, const QStringList &values) - { - QString s = (sender) ? sender->metaObject()->className() : ""; - qDebug() << "signal" << s << values; - } - - void CRuntime::logSlot(const char *func, const QString ¶m) const - { - qDebug() << func << param; - } - - void CRuntime::logSlot(const char *func, const QStringList ¶ms) const - { - qDebug() << func << params; - } - - void CRuntime::logSlot(const char *func, bool boolValue) const - { - qDebug() << func << boolValue; - } - - void CRuntime::logSlot(CRuntime::LogContext context, const char *func, const QString ¶m) const - { - if (this->isSlotLogEnabledFor(context)) qDebug() << func << param; - } - - void CRuntime::logSlot(CRuntime::LogContext context, const char *func, const QStringList ¶ms) const - { - if (this->isSlotLogEnabledFor(context)) qDebug() << func << params; - } - - void CRuntime::logSlot(CRuntime::LogContext context, const char *func, bool boolValue) const - { - if (this->isSlotLogEnabledFor(context)) qDebug() << func << boolValue; - } - - bool CRuntime::isSlotLogEnabledFor(CRuntime::LogContext context) const - { - switch (context) - { - default: return true; - case LogForApplication: return this->isSlotLogForApplicationEnabled(); - case LogForAudio: return this->isSlotLogForAudioEnabled(); - case LogForNetwork: return this->isSlotLogForNetworkEnabled(); - case LogForOwnAircraft: return this->isSlotLogForOwnAircraftEnabled(); - case LogForSettings: return this->isSlotLogForSettingsEnabled(); - case LogForSimulator: return this->isSlotLogForSimulatorEnabled(); - } - } - /* * Init runtime */ @@ -467,8 +201,7 @@ namespace BlackCore if (!this->m_init) return; this->m_init = false; - // disable all logging and all signals towards runtime - this->signalLog(false); + // disable all signals towards runtime disconnect(this); // unregister all from DBus @@ -520,9 +253,6 @@ namespace BlackCore if (this->getIContextApplication()) { disconnect(this->getIContextApplication()); - this->getIContextApplication()->setOutputRedirectionLevel(IContextApplication::RedirectNone); - this->getIContextApplication()->setStreamingForRedirectedOutputLevel(IContextApplication::RedirectNone); - IContextApplication::resetOutputRedirection(); this->getIContextApplication()->deleteLater(); this->m_contextApplication = nullptr; } @@ -540,16 +270,6 @@ namespace BlackCore this->getIContextApplication()->sendStatusMessages(messages); } - void CRuntime::disconnectLogSignals(const QString &name) - { - if (!this->m_logSignalConnections.contains(name)) return; - for (auto i = this->m_logSignalConnections.lowerBound(name), end = this->m_logSignalConnections.upperBound(name); i != end; ++i) - { - disconnect(i.value()); - } - this->m_logSignalConnections.remove(name); - } - void CRuntime::initDBusConnection(const QString &address) { if (this->m_initDBusConnection) return; diff --git a/src/blackcore/context_runtime.h b/src/blackcore/context_runtime.h index 46dc030cd..13322c311 100644 --- a/src/blackcore/context_runtime.h +++ b/src/blackcore/context_runtime.h @@ -36,17 +36,6 @@ namespace BlackCore public: //! Log message category static QString getMessageCategory() { return "swift.runtime"; } - //! Tags to identify the context when logging a slot - enum LogContext - { - LogDefault = 0, - LogForApplication, - LogForAudio, - LogForNetwork, - LogForOwnAircraft, - LogForSettings, - LogForSimulator - }; //! Constructor CRuntime(const CRuntimeConfig &config, QObject *parent = nullptr); @@ -60,147 +49,6 @@ namespace BlackCore //! DBus connection (if applicable) const QDBusConnection &getDBusConnection() const { return this->m_dbusConnection; } - //! Enable / disable all logging - //! \threadsafe - void signalLog(bool enabled); - - //! Signal logging for application context - //! \threadsafe - bool signalLogForApplication(bool enabled); - - //! Signal logging for audio context - //! \threadsafe - bool signalLogForAudio(bool enabled); - - //! Signal logging for network context - //! \threadsafe - bool signalLogForNetwork(bool enabled); - - //! Signal logging for own aircraft context - //! \threadsafe - bool signalLogForOwnAircraft(bool enabled); - - //! Signal logging for settings context - //! \threadsafe - bool signalLogForSettings(bool enabled); - - //! Signal logging for simulator context - //! \threadsafe - bool signalLogForSimulator(bool enabled); - - //! Enable / disable all logging - //! \threadsafe - void slotLog(bool enabled); - - //! Slot logging for application context - //! \threadsafe - void slotLogForApplication(bool enabled) - { - QWriteLocker wl(&m_lock); - this->m_slotLogApplication = enabled; - } - - //! Slot logging for audio context - //! \threadsafe - void slotLogForAudio(bool enabled) - { - QWriteLocker wl(&m_lock); - this->m_slotLogAudio = enabled; - } - - //! Slot logging for network context - //! \threadsafe - void slotLogForNetwork(bool enabled) - { - QWriteLocker wl(&m_lock); - this->m_slotLogNetwork = enabled; - } - - //! Slot logging for own aircraft context - //! \threadsafe - void slotLogForOwnAircraft(bool enabled) - { - QWriteLocker wl(&m_lock); - this->m_slotLogOwnAircraft = enabled; - } - - //! Slot logging for settings context - //! \threadsafe - void slotLogForSettings(bool enabled) - { - QWriteLocker wl(&m_lock); - this->m_slotLogSettings = enabled; - } - - //! Slot logging for simulator context - //! \threadsafe - void slotLogForSimulator(bool enabled) - { - QWriteLocker wl(&m_lock); - this->m_slotLogSimulator = enabled; - } - - //! Slot logging for application context - //! \threadsafe - bool isSlotLogForApplicationEnabled() const - { - QReadLocker rl(&m_lock); - return this->m_slotLogApplication; - } - - //! Slot logging for audio context - //! \threadsafe - bool isSlotLogForAudioEnabled() const - { - QReadLocker rl(&m_lock); - return this->m_slotLogAudio; - } - - //! Slot logging for network context - //! \threadsafe - bool isSlotLogForNetworkEnabled() const - { - QReadLocker rl(&m_lock); - return this->m_slotLogNetwork; - } - - //! Slot log for own aircraft - //! \threadsafe - bool isSlotLogForOwnAircraftEnabled() const - { - QReadLocker rl(&m_lock); - return this->m_slotLogOwnAircraft; - } - - //! Slot logging for settings context - //! \threadsafe - bool isSlotLogForSettingsEnabled() const - { - QReadLocker rl(&m_lock); - return this->m_slotLogSettings; - } - - //! Slot logging for simulator context - //! \threadsafe - bool isSlotLogForSimulatorEnabled() const - { - QReadLocker rl(&m_lock); - return this->m_slotLogSimulator; - } - - //! Slot logging for specified context - //! \threadsafe - bool isSlotLogEnabledFor(LogContext context) const; - - //! Slot logging from a specific context - void logSlot(LogContext ctx, const char *func, const QString ¶m = "") const; - - //! Slot logging from a specific context - void logSlot(LogContext ctx, const char *func, const QStringList ¶ms) const; - - //! Slot logging for bool value from a specific context - void logSlot(LogContext ctx, const char *func, bool boolValue) const; - //! Clean up (will be connected to signal QCoreApplication::aboutToQuit) void gracefulShutdown(); @@ -305,18 +153,6 @@ namespace BlackCore bool m_init; /*!< flag */ CDBusServer *m_dbusServer; bool m_initDBusConnection; - bool m_signalLogApplication; - bool m_signalLogAudio; - bool m_signalLogNetwork; - bool m_signalLogOwnAircraft; - bool m_signalLogSettings; - bool m_signalLogSimulator; - bool m_slotLogApplication; - bool m_slotLogAudio; - bool m_slotLogNetwork; - bool m_slotLogOwnAircraft; - bool m_slotLogSettings; - bool m_slotLogSimulator; QDBusConnection m_dbusConnection; IContextApplication *m_contextApplication; IContextAudio *m_contextAudio; @@ -324,7 +160,6 @@ namespace BlackCore IContextOwnAircraft *m_contextOwnAircraft; IContextSettings *m_contextSettings; IContextSimulator *m_contextSimulator; - QMultiMap m_logSignalConnections; mutable QReadWriteLock m_lock; //! initialization of DBus connection (where applicable) @@ -335,21 +170,6 @@ namespace BlackCore //! post init tasks, mainly connecting context signal slots void initPostSetup(); - - //! log - void logSignal(QObject *sender, const QStringList &values); - - //! disconnect log signals (connected via connection to log them) - void disconnectLogSignals(const QString &name); - - //! Slot logging - void logSlot(const char *func, const QString ¶m = "") const; - - //! Slot logging - void logSlot(const char *func, const QStringList ¶ms) const; - - //! Slot logging for bool value - void logSlot(const char *func, bool boolValue) const; }; } #endif // guard diff --git a/src/blackcore/context_simulator_impl.h b/src/blackcore/context_simulator_impl.h index ff7104ed0..22912cfe3 100644 --- a/src/blackcore/context_simulator_impl.h +++ b/src/blackcore/context_simulator_impl.h @@ -128,8 +128,6 @@ namespace BlackCore void ps_textMessagesReceived(const BlackMisc::Network::CTextMessageList &textMessages); private: - static const auto c_logContext = CRuntime::LogForSimulator; - //! \brief find and catalog all simulator plugins void findSimulatorPlugins(); diff --git a/src/swiftgui_standard/mainwindow.cpp b/src/swiftgui_standard/mainwindow.cpp index 70374a01e..532d98dee 100644 --- a/src/swiftgui_standard/mainwindow.cpp +++ b/src/swiftgui_standard/mainwindow.cpp @@ -323,13 +323,6 @@ void MainWindow::ps_displayStatusMessagesInGui(const CStatusMessageList &message } } -void MainWindow::displayRedirectedOutput(const CStatusMessage &statusMessage, qint64 contextId) -{ - if (!this->getIContextApplication()) return; - if (this->getIContextApplication()->getUniqueId() == contextId) return; //self triggered - this->ui->comp_MainInfoArea->getLogComponent()->appendStatusMessageToConsole(statusMessage); -} - void MainWindow::ps_onChangedSetttings(uint typeValue) { IContextSettings::SettingsType type = static_cast(typeValue); diff --git a/src/swiftgui_standard/mainwindow.h b/src/swiftgui_standard/mainwindow.h index 59120d594..83a4b6ab7 100644 --- a/src/swiftgui_standard/mainwindow.h +++ b/src/swiftgui_standard/mainwindow.h @@ -187,9 +187,6 @@ private slots: //! Display status messages void ps_displayStatusMessagesInGui(const BlackMisc::CStatusMessageList &messages); - //! Redirected output - void displayRedirectedOutput(const BlackMisc::CStatusMessage &sendStatusMessage, qint64 contextId); - //! Settings have been changed void ps_onChangedSetttings(uint typeValue); diff --git a/src/swiftgui_standard/mainwindow_init.cpp b/src/swiftgui_standard/mainwindow_init.cpp index ab74fa756..30586e366 100644 --- a/src/swiftgui_standard/mainwindow_init.cpp +++ b/src/swiftgui_standard/mainwindow_init.cpp @@ -98,7 +98,6 @@ void MainWindow::init(const CRuntimeConfig &runtimeConfig) bool connect; this->connect(this->getIContextApplication(), &IContextApplication::statusMessage, this, &MainWindow::ps_displayStatusMessageInGui); this->connect(this->getIContextApplication(), &IContextApplication::statusMessages, this, &MainWindow::ps_displayStatusMessagesInGui); - this->connect(this->getIContextApplication(), &IContextApplication::redirectedOutput, this, &MainWindow::displayRedirectedOutput); this->connect(this->getIContextNetwork(), &IContextNetwork::connectionTerminated, this, &MainWindow::ps_onConnectionTerminated); this->connect(this->getIContextNetwork(), &IContextNetwork::connectionStatusChanged, this, &MainWindow::ps_onConnectionStatusChanged); connect = this->connect(this->getIContextNetwork(), SIGNAL(textMessagesReceived(BlackMisc::Network::CTextMessageList)), this->ui->comp_MainInfoArea->getTextMessageComponent(), SLOT(appendTextMessagesToGui(BlackMisc::Network::CTextMessageList)));