diff --git a/src/blackcore/airspace_watchdog.cpp b/src/blackcore/airspace_watchdog.cpp index 6ac8490a1..fbc01adaa 100644 --- a/src/blackcore/airspace_watchdog.cpp +++ b/src/blackcore/airspace_watchdog.cpp @@ -63,7 +63,7 @@ namespace BlackCore QDateTime timestamp = m_callsignTimestamps.value(callsign); if (timestamp.secsTo(QDateTime::currentDateTimeUtc()) > m_timeout.value(CTimeUnit::s())) { - CLogMessage().debug(this) << "Aircraft " << callsign.toQString() << "timed out!"; + CLogMessage(this).debug() << "Aircraft " << callsign.toQString() << "timed out!"; m_callsignTimestamps.remove(callsign); emit timeout(callsign); } diff --git a/src/blackcore/context.cpp b/src/blackcore/context.cpp index 9daa1063d..f2c1cd536 100644 --- a/src/blackcore/context.cpp +++ b/src/blackcore/context.cpp @@ -76,7 +76,7 @@ namespace BlackCore const CStatusMessage &CContext::statusMessageEmptyContext() { - static const CStatusMessage m("swift.context.emptycontext", CStatusMessage::SeverityWarning, "empty context"); + static const CStatusMessage m(getLogCategories(), CStatusMessage::SeverityWarning, "empty context"); return m; } } // namespace diff --git a/src/blackcore/context.h b/src/blackcore/context.h index dbe793c5a..5cab03e4e 100644 --- a/src/blackcore/context.h +++ b/src/blackcore/context.h @@ -26,6 +26,13 @@ namespace BlackCore //! Destructor ~CContext() {} + //! Log category + static const CLogCategoryList &getLogCategories() + { + static const CLogCategoryList cats { CLogCategory::context() }; + return cats; + } + //! Using local implementing object? bool isUsingImplementingObject() const { diff --git a/src/blackcore/context_application_impl.cpp b/src/blackcore/context_application_impl.cpp index 557233994..45fa78ab1 100644 --- a/src/blackcore/context_application_impl.cpp +++ b/src/blackcore/context_application_impl.cpp @@ -48,7 +48,7 @@ namespace BlackCore */ void CContextApplication::notifyAboutComponentChange(uint component, uint action) { - CLogMessage().debug(this) << Q_FUNC_INFO << QString::number(component) << QString::number(action); + CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << QString::number(component) << QString::number(action); this->componentChanged(component, action); } @@ -57,7 +57,7 @@ namespace BlackCore */ bool CContextApplication::writeToFile(const QString &fileName, const QString &content) { - CLogMessage().debug(this) << Q_FUNC_INFO << fileName << content.left(25); + CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << fileName << content.left(25); if (fileName.isEmpty()) return false; QFile file(fileName); if (file.open(QIODevice::WriteOnly | QIODevice::Text)) @@ -74,7 +74,7 @@ namespace BlackCore */ QString CContextApplication::readFromFile(const QString &fileName) { - CLogMessage().debug(this) << Q_FUNC_INFO << fileName; + CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << fileName; QFile file(fileName); QString content; if (fileName.isEmpty()) return content; diff --git a/src/blackcore/context_audio_impl.cpp b/src/blackcore/context_audio_impl.cpp index 68e228857..38677d673 100644 --- a/src/blackcore/context_audio_impl.cpp +++ b/src/blackcore/context_audio_impl.cpp @@ -76,7 +76,7 @@ namespace BlackCore CVoiceRoomList CContextAudio::getComVoiceRoomsWithAudioStatus() const { Q_ASSERT(this->m_voice); - CLogMessage().debug(this) << Q_FUNC_INFO; + CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; return getComVoiceRooms(); } @@ -86,7 +86,7 @@ namespace BlackCore CVoiceRoom CContextAudio::getCom1VoiceRoom(bool withAudioStatus) const { Q_ASSERT(this->m_voice); - CLogMessage().debug(this) << Q_FUNC_INFO << withAudioStatus; + CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << withAudioStatus; // We always have the audio status due to shared status return m_channelCom1->getVoiceRoom(); } @@ -97,7 +97,7 @@ namespace BlackCore CVoiceRoom CContextAudio::getCom2VoiceRoom(bool withAudioStatus) const { Q_ASSERT(this->m_voice); - CLogMessage().debug(this) << Q_FUNC_INFO << withAudioStatus; + CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << withAudioStatus; // We always have the audio status due to shared status return m_channelCom2->getVoiceRoom(); } @@ -108,7 +108,7 @@ namespace BlackCore CVoiceRoomList CContextAudio::getComVoiceRooms() const { Q_ASSERT(this->m_voice); - CLogMessage().debug(this) << Q_FUNC_INFO; + CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; CVoiceRoomList voiceRoomList; voiceRoomList.push_back(m_channelCom1->getVoiceRoom()); voiceRoomList.push_back(m_channelCom2->getVoiceRoom()); @@ -121,7 +121,7 @@ namespace BlackCore void CContextAudio::leaveAllVoiceRooms() { Q_ASSERT(this->m_voice); - CLogMessage().debug(this) << Q_FUNC_INFO; + CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; m_channelCom1->leaveVoiceRoom(); m_channelCom2->leaveVoiceRoom(); } @@ -132,7 +132,7 @@ namespace BlackCore CAudioDeviceList CContextAudio::getAudioDevices() const { Q_ASSERT(this->m_voice); - CLogMessage().debug(this) << Q_FUNC_INFO; + CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; return this->m_voice->audioDevices(); } @@ -142,7 +142,7 @@ namespace BlackCore CAudioDeviceList CContextAudio::getCurrentAudioDevices() const { Q_ASSERT(this->m_voice); - CLogMessage().debug(this) << Q_FUNC_INFO; + CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; CAudioDeviceList devices; devices.push_back(this->m_voice->getCurrentInputDevice()); devices.push_back(this->m_voice->getCurrentOutputDevice()); @@ -156,7 +156,7 @@ namespace BlackCore { Q_ASSERT(this->m_voice); Q_ASSERT(audioDevice.getType() != CAudioDevice::Unknown); - CLogMessage().debug(this) << Q_FUNC_INFO << audioDevice; + CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << audioDevice; if (audioDevice.getType() == CAudioDevice::InputDevice) { this->m_voice->setInputDevice(audioDevice); @@ -173,7 +173,7 @@ namespace BlackCore void CContextAudio::setVolumes(const CComSystem &com1, const CComSystem &com2) { Q_ASSERT(this->m_voice); - CLogMessage().debug(this) << Q_FUNC_INFO << com1 << com2; + CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << com1 << com2; // volumes qint32 vol1 = com1.getVolumeOutput(); @@ -192,7 +192,7 @@ namespace BlackCore bool CContextAudio::isMuted() const { Q_ASSERT(this->m_voice); - CLogMessage().debug(this) << Q_FUNC_INFO; + CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; return m_channelCom1->isMuted() && m_channelCom2->isMuted(); } @@ -203,7 +203,7 @@ namespace BlackCore { Q_ASSERT(this->m_voice); Q_ASSERT(newRooms.size() == 2); - CLogMessage().debug(this) << Q_FUNC_INFO << newRooms; + CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << newRooms; CVoiceRoomList currentRooms = getComVoiceRooms(); CVoiceRoom currentRoom1 = currentRooms[0]; @@ -244,7 +244,7 @@ namespace BlackCore CCallsignList CContextAudio::getCom1RoomCallsigns() const { Q_ASSERT(this->m_voice); - CLogMessage().debug(this) << Q_FUNC_INFO; + CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; return m_channelCom1->getVoiceRoomCallsigns(); } @@ -254,7 +254,7 @@ namespace BlackCore CCallsignList CContextAudio::getCom2RoomCallsigns() const { Q_ASSERT(this->m_voice); - CLogMessage().debug(this) << Q_FUNC_INFO; + CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; return m_channelCom2->getVoiceRoomCallsigns(); } @@ -266,7 +266,7 @@ namespace BlackCore Q_ASSERT(this->m_voice); Q_ASSERT(this->getRuntime()); if (!this->getRuntime()->getIContextNetwork()) return Network::CUserList(); - CLogMessage().debug(this) << Q_FUNC_INFO; + CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; return this->getIContextNetwork()->getUsersForCallsigns(this->getCom1RoomCallsigns()); } @@ -278,7 +278,7 @@ namespace BlackCore Q_ASSERT(this->m_voice); Q_ASSERT(this->getRuntime()); if (!this->getRuntime()->getIContextNetwork()) return Network::CUserList(); - CLogMessage().debug(this) << Q_FUNC_INFO; + CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; return this->getIContextNetwork()->getUsersForCallsigns(this->getCom2RoomCallsigns()); } @@ -288,7 +288,7 @@ namespace BlackCore void CContextAudio::playSelcalTone(const CSelcal &selcal) const { Q_ASSERT(this->m_voice); - CLogMessage().debug(this) << Q_FUNC_INFO << selcal; + CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << selcal; CAudioDevice outputDevice = m_voice->getCurrentOutputDevice(); BlackSound::CSoundGenerator::playSelcal(90, selcal, outputDevice); } @@ -299,7 +299,7 @@ namespace BlackCore void CContextAudio::playNotification(uint notification, bool considerSettings) const { Q_ASSERT(this->m_voice); - CLogMessage().debug(this) << Q_FUNC_INFO << notification; + CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << notification; auto notificationSound = static_cast(notification); if (considerSettings) @@ -326,7 +326,7 @@ namespace BlackCore void CContextAudio::runMicrophoneTest() { Q_ASSERT(this->m_voice); - CLogMessage().debug(this) << Q_FUNC_INFO; + CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; this->m_voice->runMicrophoneTest(); } @@ -336,7 +336,7 @@ namespace BlackCore void CContextAudio::runSquelchTest() { Q_ASSERT(this->m_voice); - CLogMessage().debug(this) << Q_FUNC_INFO; + CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; this->m_voice->runSquelchTest(); } @@ -346,7 +346,7 @@ namespace BlackCore QString CContextAudio::getMicrophoneTestResult() const { Q_ASSERT(this->m_voice); - CLogMessage().debug(this) << Q_FUNC_INFO; + CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; return this->m_voice->micTestResultAsString(); } @@ -356,7 +356,7 @@ namespace BlackCore double CContextAudio::getSquelchValue() const { Q_ASSERT(this->m_voice); - CLogMessage().debug(this) << Q_FUNC_INFO; + CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; return static_cast(this->m_voice->inputSquelch()); } @@ -366,7 +366,7 @@ namespace BlackCore void CContextAudio::enableAudioLoopback(bool enable) { Q_ASSERT(this->m_voice); - CLogMessage().debug(this) << Q_FUNC_INFO; + CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; m_voice->enableAudioLoopback(enable); } diff --git a/src/blackcore/context_network_impl.cpp b/src/blackcore/context_network_impl.cpp index 1f7aa3fe2..56f5d1643 100644 --- a/src/blackcore/context_network_impl.cpp +++ b/src/blackcore/context_network_impl.cpp @@ -101,29 +101,29 @@ namespace BlackCore */ CStatusMessage CContextNetwork::connectToNetwork(uint loginMode) { - CLogMessage().debug(this) << Q_FUNC_INFO; + CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; CServer currentServer = this->getIContextSettings()->getNetworkSettings().getCurrentTrafficNetworkServer(); QString msg; if (!currentServer.getUser().isValid()) { - return CLogMessage().error(this, "Invalid user credentials"); + return CLogMessage(this).error("Invalid user credentials"); } else if (!this->ownAircraft().getIcaoInfo().hasAircraftAndAirlineDesignator()) { - return CLogMessage().error(this, "Invalid ICAO data for own aircraft"); + return CLogMessage(this).error("Invalid ICAO data for own aircraft"); } else if (!CNetworkUtils::canConnect(currentServer, msg, 2000)) { - return CLogMessage().error(this, msg); + return CLogMessage(this).error(msg); } else if (this->m_network->isConnected()) { - return CLogMessage().error(this, "Already connected"); + return CLogMessage(this).error("Already connected"); } else if (this->isPendingConnection()) { - return CLogMessage().error(this, "Pending connection, please wait"); + return CLogMessage(this).error("Pending connection, please wait"); } else { @@ -137,7 +137,7 @@ namespace BlackCore this->m_network->presetIcaoCodes(ownAircraft.getIcaoInfo()); this->m_network->setOwnAircraft(ownAircraft); this->m_network->initiateConnection(); - return CLogMessage().info(this, "Connection pending %1 %2") << currentServer.getAddress() << currentServer.getPort(); + return CLogMessage(this).info("Connection pending %1 %2") << currentServer.getAddress() << currentServer.getPort(); } } @@ -146,21 +146,21 @@ namespace BlackCore */ CStatusMessage CContextNetwork::disconnectFromNetwork() { - CLogMessage().debug(this) << Q_FUNC_INFO; + CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; if (this->m_network->isConnected()) { this->m_currentStatus = INetwork::Disconnecting; // as semaphore we are going to disconnect this->m_network->terminateConnection(); this->m_airspace->clear(); - return CLogMessage().info(this, "Connection terminating"); + return CLogMessage(this).info("Connection terminating"); } else if (this->isPendingConnection()) { - return CLogMessage().warning(this, "Pending connection, please wait"); + return CLogMessage(this).warning("Pending connection, please wait"); } else { - return CLogMessage().warning(this, "Already disconnected"); + return CLogMessage(this).warning("Already disconnected"); } } @@ -169,7 +169,7 @@ namespace BlackCore */ bool CContextNetwork::isConnected() const { - CLogMessage().debug(this) << Q_FUNC_INFO; + CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; return this->m_network->isConnected(); } @@ -187,7 +187,7 @@ namespace BlackCore */ void CContextNetwork::sendTextMessages(const CTextMessageList &textMessages) { - CLogMessage().debug(this) << Q_FUNC_INFO << textMessages; + CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << textMessages; this->m_network->sendTextMessages(textMessages); } @@ -196,14 +196,14 @@ namespace BlackCore */ void CContextNetwork::sendFlightPlan(const CFlightPlan &flightPlan) { - CLogMessage().debug(this) << Q_FUNC_INFO << flightPlan; + CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << flightPlan; this->m_network->sendFlightPlan(flightPlan); this->m_network->sendFlightPlanQuery(this->ownAircraft().getCallsign()); } CFlightPlan CContextNetwork::loadFlightPlanFromNetwork(const BlackMisc::Aviation::CCallsign &callsign) const { - CLogMessage().debug(this) << Q_FUNC_INFO; + CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; return this->m_airspace->loadFlightPlanFromNetwork(callsign); } @@ -258,7 +258,7 @@ namespace BlackCore */ void CContextNetwork::ps_fsdConnectionStatusChanged(INetwork::ConnectionStatus from, INetwork::ConnectionStatus to, const QString &message) { - CLogMessage().debug(this) << Q_FUNC_INFO << from << to; + CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << from << to; auto fromOld = this->m_currentStatus; this->m_currentStatus = to; @@ -272,17 +272,17 @@ namespace BlackCore // send 1st position if (to == INetwork::Connected) { - CLogMessage().info(this, "Connected, own aircraft %1") << this->ownAircraft().toQString(); + CLogMessage(this).info("Connected, own aircraft %1") << this->ownAircraft().toQString(); } // send as message if (to == INetwork::DisconnectedError) { - CLogMessage().error(this, "Connection status changed from %1 to %2 %3") << INetwork::connectionStatusToString(from) << INetwork::connectionStatusToString(to) << message; + CLogMessage(this).error("Connection status changed from %1 to %2 %3") << INetwork::connectionStatusToString(from) << INetwork::connectionStatusToString(to) << message; } else { - CLogMessage().info(this, "Connection status changed from %1 to %2 %3") << INetwork::connectionStatusToString(from) << INetwork::connectionStatusToString(to) << message; + CLogMessage(this).info("Connection status changed from %1 to %2 %3") << INetwork::connectionStatusToString(from) << INetwork::connectionStatusToString(to) << message; } // send as own signal @@ -294,8 +294,8 @@ namespace BlackCore */ void CContextNetwork::ps_dataFileRead() { - CLogMessage().debug(this) << Q_FUNC_INFO; - CLogMessage().info(this, "Read VATSIM data file"); + CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; + CLogMessage(this).info("Read VATSIM data file"); } /* @@ -303,7 +303,7 @@ namespace BlackCore */ void CContextNetwork::ps_fsdTextMessageReceived(const CTextMessageList &messages) { - CLogMessage().debug(this) << Q_FUNC_INFO << messages; + CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << messages; this->textMessagesReceived(messages); // relay } @@ -335,7 +335,7 @@ namespace BlackCore */ void CContextNetwork::ps_receivedBookings(const CAtcStationList &) { - CLogMessage().info(this, "Read bookings from network"); + CLogMessage(this).info("Read bookings from network"); } /* @@ -374,7 +374,7 @@ namespace BlackCore */ BlackMisc::Aviation::CInformationMessage CContextNetwork::getMetar(const BlackMisc::Aviation::CAirportIcao &airportIcaoCode) { - CLogMessage().debug(this) << Q_FUNC_INFO << airportIcaoCode; + CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << airportIcaoCode; return m_airspace->getMetar(airportIcaoCode); } diff --git a/src/blackcore/context_network_impl.h b/src/blackcore/context_network_impl.h index 23a37cb02..30b418fa0 100644 --- a/src/blackcore/context_network_impl.h +++ b/src/blackcore/context_network_impl.h @@ -56,21 +56,21 @@ namespace BlackCore //! \copydoc IContextNetwork::getAtcStationsOnline() virtual const BlackMisc::Aviation::CAtcStationList getAtcStationsOnline() const override { - BlackMisc::CLogMessage().debug(this) << Q_FUNC_INFO; + BlackMisc::CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; return this->m_airspace->getAtcStationsOnline(); } //! \copydoc IContextNetwork::getAtcStationsBooked() virtual const BlackMisc::Aviation::CAtcStationList getAtcStationsBooked() const override { - BlackMisc::CLogMessage().debug(this) << Q_FUNC_INFO; + BlackMisc::CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; return this->m_airspace->getAtcStationsBooked(); } //! \copydoc IContextNetwork::getAircraftsInRange() virtual const BlackMisc::Aviation::CAircraftList getAircraftsInRange() const override { - BlackMisc::CLogMessage().debug(this) << Q_FUNC_INFO; + BlackMisc::CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; return this->m_airspace->getAircraftInRange(); } diff --git a/src/blackcore/context_ownaircraft_impl.cpp b/src/blackcore/context_ownaircraft_impl.cpp index 12fd10a9c..d2a188404 100644 --- a/src/blackcore/context_ownaircraft_impl.cpp +++ b/src/blackcore/context_ownaircraft_impl.cpp @@ -71,7 +71,7 @@ namespace BlackCore */ void CContextOwnAircraft::resolveVoiceRooms() { - CLogMessage().debug(this) << Q_FUNC_INFO; + CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; if (this->m_voiceRoom1UrlOverride.isEmpty() && this->m_voiceRoom2UrlOverride.isEmpty() && !this->m_automaticVoiceRoomResolution) return; if (!this->getIContextNetwork()) return; // no chance to resolve rooms if (!this->getIContextAudio()) return; // no place to set rooms @@ -94,7 +94,7 @@ namespace BlackCore */ void CContextOwnAircraft::updateOwnAircraft(const BlackMisc::Aviation::CAircraft &aircraft, const QString &originator) { - CLogMessage().debug(this) << Q_FUNC_INFO << ownAircraft() << originator; + CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << ownAircraft() << originator; // trigger the correct signals bool changedCockpit = this->updateOwnCockpit(aircraft.getCom1System(), aircraft.getCom2System(), aircraft.getTransponder(), originator); @@ -121,7 +121,7 @@ namespace BlackCore */ bool CContextOwnAircraft::updateOwnPosition(const BlackMisc::Geo::CCoordinateGeodetic &position, const BlackMisc::Aviation::CAltitude &altitude, const QString &originator) { - CLogMessage().debug(this) << Q_FUNC_INFO << position << altitude << originator; + CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << position << altitude << originator; bool changed = (this->m_ownAircraft.getPosition() != position); if (changed) this->m_ownAircraft.setPosition(position); @@ -144,7 +144,7 @@ namespace BlackCore */ bool CContextOwnAircraft::updateOwnSituation(const BlackMisc::Aviation::CAircraftSituation &situation, const QString &originator) { - CLogMessage().debug(this) << Q_FUNC_INFO << situation; + CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << situation; bool changed = this->m_ownAircraft.getSituation() != situation; if (!changed) return changed; @@ -162,7 +162,7 @@ namespace BlackCore */ bool CContextOwnAircraft::updateOwnCockpit(const BlackMisc::Aviation::CComSystem &com1, const BlackMisc::Aviation::CComSystem &com2, const BlackMisc::Aviation::CTransponder &transponder, const QString &originator) { - CLogMessage().debug(this) << Q_FUNC_INFO << com1 << com2 << transponder; + CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << com1 << com2 << transponder; bool changed = this->m_ownAircraft.hasChangedCockpitData(com1, com2, transponder); if (changed) { @@ -184,7 +184,7 @@ namespace BlackCore void CContextOwnAircraft::setAudioOutputVolumes(int outputVolumeCom1, int outputVolumeCom2) { - CLogMessage().debug(this) << Q_FUNC_INFO << outputVolumeCom1 << outputVolumeCom2; + CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << outputVolumeCom1 << outputVolumeCom2; CComSystem com1 = this->m_ownAircraft.getCom1System(); com1.setVolumeOutput(outputVolumeCom1); @@ -214,7 +214,7 @@ namespace BlackCore */ void CContextOwnAircraft::setAudioVoiceRoomOverrideUrls(const QString &voiceRoom1Url, const QString &voiceRoom2Url) { - CLogMessage().debug(this) << Q_FUNC_INFO << voiceRoom1Url << voiceRoom2Url; + CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << voiceRoom1Url << voiceRoom2Url; this->m_voiceRoom1UrlOverride = voiceRoom1Url.trimmed(); this->m_voiceRoom2UrlOverride = voiceRoom2Url.trimmed(); @@ -226,7 +226,7 @@ namespace BlackCore */ void CContextOwnAircraft::enableAutomaticVoiceRoomResolution(bool enable) { - CLogMessage().debug(this) << Q_FUNC_INFO << enable; + CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << enable; this->m_automaticVoiceRoomResolution = enable; } @@ -235,7 +235,7 @@ namespace BlackCore */ CAircraft CContextOwnAircraft::getOwnAircraft() const { - CLogMessage().debug(this) << Q_FUNC_INFO << this->m_ownAircraft; + CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << this->m_ownAircraft; return this->m_ownAircraft; } diff --git a/src/blackcore/context_runtime.cpp b/src/blackcore/context_runtime.cpp index 7d5a62ff8..76c0a56aa 100644 --- a/src/blackcore/context_runtime.cpp +++ b/src/blackcore/context_runtime.cpp @@ -170,7 +170,7 @@ namespace BlackCore connect(this->m_contextSettings, &IContextSettings::changedSettings, this->m_contextSimulator, &IContextSimulator::settingsChanged); if (!this->m_contextSimulator->loadSimulatorPluginFromSettings()) { - CLogMessage().warning(this, "No simulator plugin loaded"); + CLogMessage(this).warning("No simulator plugin loaded"); } } } diff --git a/src/blackcore/context_settings_impl.cpp b/src/blackcore/context_settings_impl.cpp index e2b416ca6..ff11fd52f 100644 --- a/src/blackcore/context_settings_impl.cpp +++ b/src/blackcore/context_settings_impl.cpp @@ -33,7 +33,7 @@ namespace BlackCore { if (!CSettingUtilities::initSettingsDirectory()) { - return CLogMessage().error(this, "Cannot init directory: %1") << this->getSettingsDirectory(); + return CLogMessage(this).error("Cannot init directory: %1") << this->getSettingsDirectory(); } bool ok = false; QFile jsonFile(this->getSettingsFileName()); @@ -94,11 +94,11 @@ namespace BlackCore if (ok) { - return CLogMessage().info(this, "Read settings: %1") << this->getSettingsFileName(); + return CLogMessage(this).info("Read settings: %1") << this->getSettingsFileName(); } else { - return CLogMessage().error(this, "Problem reading settings: %1") << this->getSettingsFileName(); + return CLogMessage(this).error("Problem reading settings: %1") << this->getSettingsFileName(); } } @@ -109,7 +109,7 @@ namespace BlackCore { if (!CSettingUtilities::initSettingsDirectory()) { - return CLogMessage().error(this, "Cannot init directory: %1") << this->getSettingsDirectory(); + return CLogMessage(this).error("Cannot init directory: %1") << this->getSettingsDirectory(); } QFile jsonFile(this->getSettingsFileName()); bool ok = false; @@ -121,11 +121,11 @@ namespace BlackCore } if (ok) { - return CLogMessage().info(this, "Written settings: %1") << this->getSettingsFileName(); + return CLogMessage(this).info("Written settings: %1") << this->getSettingsFileName(); } else { - return CLogMessage().error(this, "Problem writing settings: %1") << this->getSettingsFileName(); + return CLogMessage(this).error("Problem writing settings: %1") << this->getSettingsFileName(); } } @@ -142,7 +142,7 @@ namespace BlackCore if (write) return this->write(); else - return CLogMessage().info(this, "Reset settings data, not written"); + return CLogMessage(this).info("Reset settings data, not written"); } QString CContextSettings::getSettingsAsJsonString() const @@ -264,7 +264,7 @@ namespace BlackCore } else { - msgs.push_back(CLogMessage().error(CSettingUtilities::validationMessageCategory(), "wrong path: %1") << path); + msgs.push_back(CLogMessage(CLogCategory::validation()).error("wrong path: %1") << path); } return msgs; } diff --git a/src/blackcore/context_simulator_impl.cpp b/src/blackcore/context_simulator_impl.cpp index 381c7f595..da75ac57c 100644 --- a/src/blackcore/context_simulator_impl.cpp +++ b/src/blackcore/context_simulator_impl.cpp @@ -54,42 +54,42 @@ namespace BlackCore bool CContextSimulator::isConnected() const { - CLogMessage().debug(this) << Q_FUNC_INFO; + CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; if (!m_simulator) return false; return m_simulator->isConnected(); } bool CContextSimulator::canConnect() { - CLogMessage().debug(this) << Q_FUNC_INFO; + CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; if (!m_simulator) return false; return m_simulator->canConnect(); } bool CContextSimulator::connectTo() { - CLogMessage().debug(this) << Q_FUNC_INFO; + CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; if (!m_simulator) return false; return m_simulator->connectTo(); } void CContextSimulator::asyncConnectTo() { - CLogMessage().debug(this) << Q_FUNC_INFO; + CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; if (!m_simulator || m_canConnectResult.isRunning()) return; // already checking m_simulator->asyncConnectTo(); } bool CContextSimulator::disconnectFrom() { - CLogMessage().debug(this) << Q_FUNC_INFO; + CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; if (!m_simulator) return false; return m_simulator->disconnectFrom(); } BlackSim::CSimulatorInfo CContextSimulator::getSimulatorInfo() const { - CLogMessage().debug(this) << Q_FUNC_INFO; + CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO; if (!m_simulator) return BlackSim::CSimulatorInfo::UnspecifiedSim(); return m_simulator->getSimulatorInfo(); } @@ -139,7 +139,7 @@ namespace BlackCore // warning if we do not have any plugins if (m_simulatorFactories.isEmpty()) { - CLogMessage().error(this, "No simulator plugins"); + CLogMessage(this).error("No simulator plugins"); return false; } @@ -151,7 +151,7 @@ namespace BlackCore // no plugin found if (iterator == m_simulatorFactories.end()) { - CLogMessage().error(this, "Plugin not found: '%1'") << simulatorInfo.toQString(true); + CLogMessage(this).error("Plugin not found: '%1'") << simulatorInfo.toQString(true); return false; } @@ -185,7 +185,7 @@ namespace BlackCore asyncConnectTo(); // info about what is going on - CLogMessage().info(this, "Simulator plugin loaded: '%1'") << this->m_simulator->getSimulatorInfo().toQString(true); + CLogMessage(this).info("Simulator plugin loaded: '%1'") << this->m_simulator->getSimulatorInfo().toQString(true); return true; } @@ -345,11 +345,11 @@ namespace BlackCore { if (this->loadSimulatorPlugin(plugin)) { - CLogMessage().info(this, "Plugin loaded: '%1'") << plugin.toQString(true); + CLogMessage(this).info("Plugin loaded: '%1'") << plugin.toQString(true); } else { - CLogMessage().error(this, "Cannot load driver: '%1'") << plugin.toQString(true); + CLogMessage(this).error("Cannot load driver: '%1'") << plugin.toQString(true); } } @@ -371,7 +371,7 @@ namespace BlackCore m_pluginsDir = QDir(path); if (!m_pluginsDir.exists()) { - CLogMessage().error(this, "No plugin directory: %1") << m_pluginsDir.currentPath(); + CLogMessage(this).error("No plugin directory: %1") << m_pluginsDir.currentPath(); return; } @@ -395,7 +395,7 @@ namespace BlackCore } else { - CLogMessage().error(this, loader.errorString()); + CLogMessage(this).error(loader.errorString()); qDebug() << "Also check if required dll/libs of plugin exists"; } } diff --git a/src/blackcore/network_vatlib.cpp b/src/blackcore/network_vatlib.cpp index 664efb12c..b61120451 100644 --- a/src/blackcore/network_vatlib.cpp +++ b/src/blackcore/network_vatlib.cpp @@ -1089,26 +1089,26 @@ namespace BlackCore auto *self = cbvar_cast(cbvar); switch (type) { - case Cvatlib_Network::error_CallsignTaken: CLogMessage().error(self, "The requested callsign is already taken"); emit self->terminate(); break; - case Cvatlib_Network::error_CallsignInvalid: CLogMessage().error(self, "The requested callsign is not valid"); emit self->terminate(); break; - case Cvatlib_Network::error_CIDPasswdInvalid: CLogMessage().error(self, "Wrong user ID or password"); emit self->terminate(); break; - case Cvatlib_Network::error_ProtoVersion: CLogMessage().error(self, "This server does not support our protocol version"); emit self->terminate(); break; - case Cvatlib_Network::error_LevelTooHigh: CLogMessage().error(self, "You are not authorized to use the requested pilot rating"); emit self->terminate(); break; - case Cvatlib_Network::error_ServerFull: CLogMessage().error(self, "The server is full"); emit self->terminate(); break; - case Cvatlib_Network::error_CIDSuspended: CLogMessage().error(self, "Your user account is suspended"); emit self->terminate(); break; - case Cvatlib_Network::error_InvalidPosition: CLogMessage().error(self, "You are not authorized to use the requested pilot rating"); emit self->terminate(); break; - case Cvatlib_Network::error_SoftwareNotAuthorized: CLogMessage().error(self, "This software is not authorized for use on this network"); emit self->terminate(); break; + case Cvatlib_Network::error_CallsignTaken: CLogMessage(self).error("The requested callsign is already taken"); emit self->terminate(); break; + case Cvatlib_Network::error_CallsignInvalid: CLogMessage(self).error("The requested callsign is not valid"); emit self->terminate(); break; + case Cvatlib_Network::error_CIDPasswdInvalid: CLogMessage(self).error("Wrong user ID or password"); emit self->terminate(); break; + case Cvatlib_Network::error_ProtoVersion: CLogMessage(self).error("This server does not support our protocol version"); emit self->terminate(); break; + case Cvatlib_Network::error_LevelTooHigh: CLogMessage(self).error("You are not authorized to use the requested pilot rating"); emit self->terminate(); break; + case Cvatlib_Network::error_ServerFull: CLogMessage(self).error("The server is full"); emit self->terminate(); break; + case Cvatlib_Network::error_CIDSuspended: CLogMessage(self).error("Your user account is suspended"); emit self->terminate(); break; + case Cvatlib_Network::error_InvalidPosition: CLogMessage(self).error("You are not authorized to use the requested pilot rating"); emit self->terminate(); break; + case Cvatlib_Network::error_SoftwareNotAuthorized: CLogMessage(self).error("This software is not authorized for use on this network"); emit self->terminate(); break; - case Cvatlib_Network::error_Ok: CLogMessage().info(self, "OK"); break; - case Cvatlib_Network::error_Syntax: CLogMessage().info(self, "Malformed packet: Syntax error: %1") << self->fromFSD(data); break; - case Cvatlib_Network::error_SourceInvalid: CLogMessage().info(self, "Server: source invalid %1") << self->fromFSD(data); break; - case Cvatlib_Network::error_CallsignNotExists: CLogMessage().info(self, "Shim lib: %1 (%2)") << self->fromFSD(msg) << self->fromFSD(data); break; - case Cvatlib_Network::error_NoFP: CLogMessage().info(self, "Server: no flight plan"); break; - case Cvatlib_Network::error_NoWeather: CLogMessage().info(self, "Server: requested weather profile does not exist"); break; + case Cvatlib_Network::error_Ok: CLogMessage(self).info("OK"); break; + case Cvatlib_Network::error_Syntax: CLogMessage(self).info("Malformed packet: Syntax error: %1") << self->fromFSD(data); break; + case Cvatlib_Network::error_SourceInvalid: CLogMessage(self).info("Server: source invalid %1") << self->fromFSD(data); break; + case Cvatlib_Network::error_CallsignNotExists: CLogMessage(self).info("Shim lib: %1 (%2)") << self->fromFSD(msg) << self->fromFSD(data); break; + case Cvatlib_Network::error_NoFP: CLogMessage(self).info("Server: no flight plan"); break; + case Cvatlib_Network::error_NoWeather: CLogMessage(self).info("Server: requested weather profile does not exist"); break; // we have no idea what these mean case Cvatlib_Network::error_Registered: - case Cvatlib_Network::error_InvalidControl: CLogMessage().info(self, "Server: ") << self->fromFSD(msg); break; + case Cvatlib_Network::error_InvalidControl: CLogMessage(self).info("Server: ") << self->fromFSD(msg); break; default: qFatal("VATSIM shim library: %s (error %d)", msg, type); emit self->terminate(); } diff --git a/src/blackcore/voice_channel_vatlib.cpp b/src/blackcore/voice_channel_vatlib.cpp index a44121ca4..e6102ae69 100644 --- a/src/blackcore/voice_channel_vatlib.cpp +++ b/src/blackcore/voice_channel_vatlib.cpp @@ -140,21 +140,21 @@ namespace BlackCore catch (const NetworkNotConnectedException &e) { // this could be caused by a race condition during normal operation, so not an error - CLogMessage().debug(q) << "NetworkNotConnectedException" << e.what() << "in" << caller; + CLogMessage(q).debug() << "NetworkNotConnectedException" << e.what() << "in" << caller; } catch (const VatlibException &e) { - CLogMessage().error(q, "VatlibException %1 in %2") << e.what() << caller; + CLogMessage(q).error("VatlibException %1 in %2") << e.what() << caller; Q_ASSERT(false); } catch (const std::exception &e) { - CLogMessage().error(q, "std::exception %1 in %2") << e.what() << caller; + CLogMessage(q).error("std::exception %1 in %2") << e.what() << caller; Q_ASSERT(false); } catch (...) { - CLogMessage().error(q, "Unknown exception in %1") << caller; + CLogMessage(q).error("Unknown exception in %1") << caller; Q_ASSERT(false); } } diff --git a/src/blackcore/voice_vatlib.cpp b/src/blackcore/voice_vatlib.cpp index b81f460c6..e2f6b5347 100644 --- a/src/blackcore/voice_vatlib.cpp +++ b/src/blackcore/voice_vatlib.cpp @@ -430,21 +430,21 @@ namespace BlackCore catch (const NetworkNotConnectedException &e) { // this could be caused by a race condition during normal operation, so not an error - CLogMessage().debug(this) << "NetworkNotConnectedException" << e.what() << "in" << caller; + CLogMessage(this).debug() << "NetworkNotConnectedException" << e.what() << "in" << caller; } catch (const VatlibException &e) { - CLogMessage().error(this, "VatlibException %1 in %2") << e.what() << caller; + CLogMessage(this).error("VatlibException %1 in %2") << e.what() << caller; Q_ASSERT(false); } catch (const std::exception &e) { - CLogMessage().error(this, "std::exception %1 in %2") << e.what() << caller; + CLogMessage(this).error("std::exception %1 in %2") << e.what() << caller; Q_ASSERT(false); } catch (...) { - CLogMessage().error(this, "Unknown exception in %1") << caller; + CLogMessage(this).error("Unknown exception in %1") << caller; Q_ASSERT(false); } } diff --git a/src/blackgui/components/atcstationcomponent.cpp b/src/blackgui/components/atcstationcomponent.cpp index b21b3f5ec..ae7806f07 100644 --- a/src/blackgui/components/atcstationcomponent.cpp +++ b/src/blackgui/components/atcstationcomponent.cpp @@ -169,7 +169,7 @@ namespace BlackGui if (sender == this->ui->tvp_AtcStationsBooked && this->getIContextNetwork()) { // trigger new read, which takes some time. A signal will be received when this is done - CLogMessage().info(this, "Requested new bookings"); + CLogMessage(this).info("Requested new bookings"); this->getIContextNetwork()->readAtcBookingsFromSource(); } else diff --git a/src/blackgui/components/cockpitv1component.cpp b/src/blackgui/components/cockpitv1component.cpp index 961bbd613..9e890698d 100644 --- a/src/blackgui/components/cockpitv1component.cpp +++ b/src/blackgui/components/cockpitv1component.cpp @@ -222,7 +222,7 @@ namespace BlackGui } else { - CLogMessage().error(validationMessageCategory(), "Wrong transponder code, reset"); + CLogMessage(CLogCategory::validation()).error("Wrong transponder code, reset"); this->ui->ds_CockpitTransponder->setValue(transponder.getTransponderCode()); } transponder.setTransponderMode(this->ui->cbp_CockpitTransponderMode->getSelectedTransponderMode()); @@ -392,7 +392,7 @@ namespace BlackGui QString selcalCode = this->getSelcalCode(); if (!CSelcal::isValidCode(selcalCode)) { - CLogMessage().error(validationMessageCategory(), "Invalid SELCAL codde"); + CLogMessage(CLogCategory::validation()).error("Invalid SELCAL codde"); } else if (this->getIContextAudio()) { @@ -401,7 +401,7 @@ namespace BlackGui } else { - CLogMessage().error(validationMessageCategory(), "No audio available"); + CLogMessage(CLogCategory::validation()).error("No audio available"); } } diff --git a/src/blackgui/components/flightplancomponent.cpp b/src/blackgui/components/flightplancomponent.cpp index 59eaa3e5e..7b64b3fd4 100644 --- a/src/blackgui/components/flightplancomponent.cpp +++ b/src/blackgui/components/flightplancomponent.cpp @@ -110,17 +110,17 @@ namespace BlackGui v = ui->le_Callsign->text().trimmed(); if (v.isEmpty()) { - messages.push_back(CLogMessage().error(validationMessageCategory(), "Missing %1") << this->ui->lbl_Callsign->text()); + messages.push_back(CLogMessage(CLogCategory::validation()).error("Missing %1") << this->ui->lbl_Callsign->text()); } v = ui->pte_Route->toPlainText().trimmed(); if (v.isEmpty()) { - messages.push_back(CLogMessage().error(validationMessageCategory(), "Missing flight plan route")); + messages.push_back(CLogMessage(CLogCategory::validation()).error("Missing flight plan route")); } else if (v.length() > CFlightPlan::MaxRouteLength) { - messages.push_back(CLogMessage().error(validationMessageCategory(), "Flight plan route length exceeded (%1 chars max.)") << CFlightPlan::MaxRouteLength); + messages.push_back(CLogMessage(CLogCategory::validation()).error("Flight plan route length exceeded (%1 chars max.)") << CFlightPlan::MaxRouteLength); } else flightPlan.setRoute(v); @@ -128,11 +128,11 @@ namespace BlackGui v = ui->pte_Remarks->toPlainText().trimmed(); if (v.isEmpty()) { - messages.push_back(CLogMessage().error(validationMessageCategory(), "No remarks, voice capabilities are mandatory")); + messages.push_back(CLogMessage(CLogCategory::validation()).error("No remarks, voice capabilities are mandatory")); } else if (v.length() > CFlightPlan::MaxRemarksLength) { - messages.push_back(CLogMessage().error(validationMessageCategory(), "Flight plan remarks length exceeded (%1 chars max.)") << CFlightPlan::MaxRemarksLength); + messages.push_back(CLogMessage(CLogCategory::validation()).error("Flight plan remarks length exceeded (%1 chars max.)") << CFlightPlan::MaxRemarksLength); } else flightPlan.setRemarks(v); @@ -140,7 +140,7 @@ namespace BlackGui v = ui->le_EstimatedTimeEnroute->text(); if (v.isEmpty() || v == defaultTime()) { - messages.push_back(CLogMessage().error(validationMessageCategory(), "Missing %1") << this->ui->lbl_EstimatedTimeEnroute->text()); + messages.push_back(CLogMessage(CLogCategory::validation()).error("Missing %1") << this->ui->lbl_EstimatedTimeEnroute->text()); } else flightPlan.setEnrouteTime(v); @@ -148,7 +148,7 @@ namespace BlackGui v = ui->le_FuelOnBoard->text(); if (v.isEmpty() || v == defaultTime()) { - messages.push_back(CLogMessage().error(validationMessageCategory(), "Missing %1") << this->ui->lbl_FuelOnBorad->text()); + messages.push_back(CLogMessage(CLogCategory::validation()).error("Missing %1") << this->ui->lbl_FuelOnBorad->text()); } else flightPlan.setFuelTime(v); @@ -156,7 +156,7 @@ namespace BlackGui v = ui->le_TakeOffTimePlanned->text(); if (v.isEmpty() || v == defaultTime()) { - messages.push_back(CLogMessage().error(validationMessageCategory(), "Missing %1") << this->ui->lbl_TakeOffTimePlanned->text()); + messages.push_back(CLogMessage(CLogCategory::validation()).error("Missing %1") << this->ui->lbl_TakeOffTimePlanned->text()); } else flightPlan.setTakeoffTimePlanned(v); @@ -172,7 +172,7 @@ namespace BlackGui CAltitude cruisingAltitude(v, CPqString::SeparatorsLocale); if (v.isEmpty() || cruisingAltitude.isNull()) { - messages.push_back(CLogMessage().error(validationMessageCategory(), "Wrong %1") << this->ui->lbl_CrusingAltitude->text()); + messages.push_back(CLogMessage(CLogCategory::validation()).error("Wrong %1") << this->ui->lbl_CrusingAltitude->text()); } else flightPlan.setCruiseAltitude(cruisingAltitude); @@ -180,7 +180,7 @@ namespace BlackGui v = this->ui->le_AlternateAirport->text(); if (v.isEmpty() || v.endsWith(defaultIcao(), Qt::CaseInsensitive)) { - messages.push_back(CLogMessage().error(validationMessageCategory(), "Missing %1") << this->ui->lbl_AlternateAirport->text()); + messages.push_back(CLogMessage(CLogCategory::validation()).error("Missing %1") << this->ui->lbl_AlternateAirport->text()); flightPlan.setAlternateAirportIcao(defaultIcao()); } else @@ -189,7 +189,7 @@ namespace BlackGui v = this->ui->le_DestinationAirport->text(); if (v.isEmpty() || v.endsWith(defaultIcao(), Qt::CaseInsensitive)) { - messages.push_back(CLogMessage().error(validationMessageCategory(), "Missing %1") << this->ui->lbl_DestinationAirport->text()); + messages.push_back(CLogMessage(CLogCategory::validation()).error("Missing %1") << this->ui->lbl_DestinationAirport->text()); flightPlan.setDestinationAirportIcao(defaultIcao()); } else @@ -200,7 +200,7 @@ namespace BlackGui cruiseTAS.parseFromString(v, CPqString::SeparatorsLocale); if (cruiseTAS.isNull()) { - messages.push_back(CLogMessage().error(validationMessageCategory(), "Wrong TAS, %1") << this->ui->lbl_CruiseTrueAirspeed->text()); + messages.push_back(CLogMessage(CLogCategory::validation()).error("Wrong TAS, %1") << this->ui->lbl_CruiseTrueAirspeed->text()); flightPlan.setDestinationAirportIcao(defaultIcao()); } else @@ -209,7 +209,7 @@ namespace BlackGui v = this->ui->le_OriginAirport->text(); if (v.isEmpty() || v.endsWith(defaultIcao(), Qt::CaseInsensitive)) { - messages.push_back(CLogMessage().error(validationMessageCategory(), "Missing %1") << this->ui->lbl_OriginAirport->text()); + messages.push_back(CLogMessage(CLogCategory::validation()).error("Missing %1") << this->ui->lbl_OriginAirport->text()); flightPlan.setOriginAirportIcao(defaultIcao()); } else @@ -230,13 +230,13 @@ namespace BlackGui flightPlan.setWhenLastSentOrLoaded(QDateTime::currentDateTimeUtc()); this->getIContextNetwork()->sendFlightPlan(flightPlan); this->ui->le_LastSent->setText(flightPlan.whenLastSentOrLoaded().toString()); - CLogMessage().info(this, "Sent flight plan"); + CLogMessage(this).info("Sent flight plan"); } else { flightPlan.setWhenLastSentOrLoaded(QDateTime()); // empty this->ui->le_LastSent->clear(); - CLogMessage().error(this, "No errors, but not connected, cannot send flight plan"); + CLogMessage(this).error("No errors, but not connected, cannot send flight plan"); } this->m_flightPlan = flightPlan; // last valid FP } @@ -272,12 +272,12 @@ namespace BlackGui { if (!this->getIContextNetwork()) { - CLogMessage().info(this, "Cannot load flight plan, network not available"); + CLogMessage(this).info("Cannot load flight plan, network not available"); return; } if (!this->getIContextNetwork()->isConnected()) { - CLogMessage().warning(this, "Cannot load flight plan, network not connected"); + CLogMessage(this).warning("Cannot load flight plan, network not connected"); return; } @@ -286,11 +286,11 @@ namespace BlackGui if (loadedPlan.wasSentOrLoaded()) { this->fillWithFlightPlanData(loadedPlan); - CLogMessage().info(this, "Updated with loaded flight plan"); + CLogMessage(this).info("Updated with loaded flight plan"); } else { - CLogMessage().warning(this, "No flight plan data"); + CLogMessage(this).warning("No flight plan data"); } } @@ -370,7 +370,7 @@ namespace BlackGui void CFlightPlanComponent::copyRemarks() { this->ui->pte_Remarks->setPlainText(this->ui->pte_RemarksGenerated->toPlainText()); - CLogMessage().info(this, "Copied remarks"); + CLogMessage(this).info("Copied remarks"); } void CFlightPlanComponent::currentTabGenerator() diff --git a/src/blackgui/components/infowindowcomponent.cpp b/src/blackgui/components/infowindowcomponent.cpp index 68d7e2c90..b58e758f3 100644 --- a/src/blackgui/components/infowindowcomponent.cpp +++ b/src/blackgui/components/infowindowcomponent.cpp @@ -90,7 +90,7 @@ namespace BlackGui } this->ui->le_SmSeverity->setText(statusMessage.getSeverityAsString()); - this->ui->le_SmType->setText(statusMessage.getCategory()); // TODO should be called ui->le_SmCategory + this->ui->le_SmType->setText(statusMessage.getCategories().toQString()); // TODO should be called ui->le_SmCategories this->ui->te_SmStatusMessage->setText(statusMessage.getMessage()); this->ui->lbl_SmSeverityIcon->setPixmap(statusMessage.toPixmap()); diff --git a/src/blackgui/components/runtimebasedcomponent.h b/src/blackgui/components/runtimebasedcomponent.h index 53955a4de..57297c4b6 100644 --- a/src/blackgui/components/runtimebasedcomponent.h +++ b/src/blackgui/components/runtimebasedcomponent.h @@ -38,10 +38,11 @@ namespace BlackGui static void setRuntimeForComponents(BlackCore::CRuntime *runtime, QWidget *parent); //! Log message category - static QString getMessageCategory() { return "swift.gui.component"; } - - //! Validation log message category - static QString validationMessageCategory() { return "swift.gui.component.validation"; } + static const CLogCategoryList &getLogCategories() + { + static const CLogCategoryList cats { CLogCategory::guiComponent() }; + return cats; + } protected: //! Constructor diff --git a/src/blackgui/components/settingscomponent.cpp b/src/blackgui/components/settingscomponent.cpp index c34c6b9ba..7747dd675 100644 --- a/src/blackgui/components/settingscomponent.cpp +++ b/src/blackgui/components/settingscomponent.cpp @@ -237,7 +237,7 @@ namespace BlackGui CServer server = this->ps_selectedServerFromTextboxes(); if (!server.isValidForLogin()) { - CLogMessage().error(validationMessageCategory(), "Wrong settings for server"); + CLogMessage(CLogCategory::validation()).error("Wrong settings for server"); return; } @@ -376,11 +376,11 @@ namespace BlackGui bool ok = CStyleSheetUtility::instance().updateFonts(fontFamily, fontSize, CStyleSheetUtility::fontStyle(fontStyleCombined), CStyleSheetUtility::fontWeight(fontStyleCombined), fontColor); if (ok) { - CLogMessage().info(this, "Updated font style"); + CLogMessage(this).info("Updated font style"); } else { - CLogMessage().info(this, "Updating style failed"); + CLogMessage(this).info("Updating style failed"); } } @@ -403,12 +403,12 @@ namespace BlackGui { if (!this->getIContextAudio()) { - CLogMessage().error(this, "voice context not available"); + CLogMessage(this).error("voice context not available"); return; } if (this->m_timerAudioTests->isActive()) { - CLogMessage().error(this, "test running, wait until completed"); + CLogMessage(this).error("test running, wait until completed"); return; } diff --git a/src/blackgui/components/settingsfsxcomponent.cpp b/src/blackgui/components/settingsfsxcomponent.cpp index 56cb349ea..4bd8cacae 100644 --- a/src/blackgui/components/settingsfsxcomponent.cpp +++ b/src/blackgui/components/settingsfsxcomponent.cpp @@ -55,28 +55,28 @@ namespace BlackGui if (address.isEmpty() || port.isEmpty()) { - CLogMessage().warning(this, "no address or port"); + CLogMessage(this).warning("no address or port"); return; } if (!CNetworkUtils::isValidIPv4Address(address)) { - CLogMessage().warning(this, "IPv4 address invalid"); + CLogMessage(this).warning("IPv4 address invalid"); return; } if (!CNetworkUtils::isValidPort(port)) { - CLogMessage().warning(this, "invalid port"); + CLogMessage(this).warning("invalid port"); return; } quint16 p = port.toUInt(); QString msg; if (!CNetworkUtils::canConnect(address, p, msg)) { - CLogMessage().warning(this, msg); + CLogMessage(this).warning(msg); return; } - CLogMessage().info(this, "Connected to %1:%2") << address << port; + CLogMessage(this).info("Connected to %1:%2") << address << port; } /* @@ -86,7 +86,7 @@ namespace BlackGui { if (!this->getIContextSimulator() || !this->getIContextSimulator()->isSimulatorAvailable()) { - CLogMessage().error(this, "Simulator not available"); + CLogMessage(this).error("Simulator not available"); return; } QString address = this->ui->le_SettingsFsxAddress->text().trimmed(); @@ -94,17 +94,17 @@ namespace BlackGui if (address.isEmpty() || port.isEmpty()) { - CLogMessage().warning(this, "no address or port"); + CLogMessage(this).warning("no address or port"); return; } if (!CNetworkUtils::isValidIPv4Address(address)) { - CLogMessage().warning(this, "IPv4 address invalid"); + CLogMessage(this).warning("IPv4 address invalid"); return; } if (!CNetworkUtils::isValidPort(port)) { - CLogMessage().warning(this, "invalid port"); + CLogMessage(this).warning("invalid port"); return; } quint16 p = port.toUInt(); @@ -117,11 +117,11 @@ namespace BlackGui this->getIContextApplication()->writeToFile(fileName, CSimConnectUtilities::simConnectCfg(address, p)); if (success) { - CLogMessage().info(this, localSimulatorObject ? "Written local %1" : "Written remote %1") << fileName; + CLogMessage(this).info(localSimulatorObject ? "Written local %1" : "Written remote %1") << fileName; } else { - CLogMessage().error(this, "Cannot write %1") << fileName; + CLogMessage(this).error("Cannot write %1") << fileName; } this->ui->pb_SettingsFsxExistsSimconncetCfg->click(); // update status } @@ -133,7 +133,7 @@ namespace BlackGui { if (!this->getIContextSimulator() || !this->getIContextSimulator()->isSimulatorAvailable()) { - CLogMessage().error(this, "Simulator not available"); + CLogMessage(this).error("Simulator not available"); return; } @@ -153,12 +153,12 @@ namespace BlackGui { QFile f(fileName); f.remove(); - CLogMessage().info(this, "Deleted locally %1") << fileName; + CLogMessage(this).info("Deleted locally %1") << fileName; } else { this->getIContextApplication()->removeFile(fileName); - CLogMessage().info(this, "Deleted remotely %1") << fileName; + CLogMessage(this).info("Deleted remotely %1") << fileName; } this->ui->pb_SettingsFsxExistsSimconncetCfg->click(); // update status } diff --git a/src/blackgui/components/settingssimulatorcomponent.cpp b/src/blackgui/components/settingssimulatorcomponent.cpp index 7e571be53..d848a8d7d 100644 --- a/src/blackgui/components/settingssimulatorcomponent.cpp +++ b/src/blackgui/components/settingssimulatorcomponent.cpp @@ -95,12 +95,12 @@ namespace BlackGui CSimulatorInfoList simDrivers = this->getIContextSimulator()->getAvailableSimulatorPlugins(); if (simDrivers.isEmpty()) { - CLogMessage().error(this, "No drivers available"); + CLogMessage(this).error("No drivers available"); return; } if (simDrivers.size() <= index) { - CLogMessage().error(this, "Wrong driver index"); + CLogMessage(this).error("Wrong driver index"); return; } @@ -146,7 +146,7 @@ namespace BlackGui } if (ost.isNull()) { - CLogMessage().error(validationMessageCategory(), "Invalid offset time"); + CLogMessage(CLogCategory::validation()).error("Invalid offset time"); } else { diff --git a/src/blackgui/components/textmessagecomponent.cpp b/src/blackgui/components/textmessagecomponent.cpp index 462b6b6b2..8dd62d7d1 100644 --- a/src/blackgui/components/textmessagecomponent.cpp +++ b/src/blackgui/components/textmessagecomponent.cpp @@ -93,7 +93,7 @@ namespace BlackGui } else { - emit this->displayInInfoWindow(CLogMessage().info(this, "SELCAL received"), 3 * 1000); + emit this->displayInInfoWindow(CLogMessage(this).info("SELCAL received"), 3 * 1000); } } continue; // not displayed @@ -382,12 +382,12 @@ namespace BlackGui { if (!this->getIContextNetwork() || !this->getIContextNetwork()->isConnected()) { - CLogMessage().error(this, "network needs to be connected"); + CLogMessage(this).error("network needs to be connected"); return; } if (parts.length() < 3) { - CLogMessage().error(this, "incorrect message"); + CLogMessage(this).error("incorrect message"); return; } QString p = parts[1].trimmed(); // receiver @@ -416,7 +416,7 @@ namespace BlackGui int index = cmdLine.indexOf(tm.getRecipientCallsign().getStringAsSet(), 0, Qt::CaseInsensitive); if (index < 0) { - CLogMessage().error(this, "incomplete message"); + CLogMessage(this).error("incomplete message"); return; } QString msg(cmdLine.mid(index + tm.getRecipientCallsign().asString().length() + 1)); @@ -438,20 +438,20 @@ namespace BlackGui // line is considered to be a message to the selected channel, send if (!this->isNetworkConnected()) { - CLogMessage().error(this, "network needs to be connected"); + CLogMessage(this).error("network needs to be connected"); return; } if (!this->isVisible()) { - CLogMessage().error(this, "text messages can only be sent from corresponding page"); + CLogMessage(this).error("text messages can only be sent from corresponding page"); return; } int index = this->currentIndex(); if (index < 0 || index == this->indexOf(this->ui->tb_TextMessagesAll)) { - CLogMessage().error(this, "incorrect channel"); + CLogMessage(this).error("incorrect channel"); } else { diff --git a/src/blackmisc/nwtextmessage.cpp b/src/blackmisc/nwtextmessage.cpp index b003a5870..94539498b 100644 --- a/src/blackmisc/nwtextmessage.cpp +++ b/src/blackmisc/nwtextmessage.cpp @@ -153,7 +153,7 @@ namespace BlackMisc CStatusMessage CTextMessage::asStatusMessage(bool withSender, bool withRecipient, const QString &separator) const { QString m = this->asString(withSender, withRecipient, separator); - return { this->getMessageCategory(), CStatusMessage::SeverityInfo, m }; + return { this, CStatusMessage::SeverityInfo, m }; } /* diff --git a/src/blackmisc/setaudio.cpp b/src/blackmisc/setaudio.cpp index 35e47805b..6e63eb1db 100644 --- a/src/blackmisc/setaudio.cpp +++ b/src/blackmisc/setaudio.cpp @@ -176,7 +176,7 @@ namespace BlackMisc return {}; } } - return CLogMessage().error(CSettingUtilities::validationMessageCategory(), "wrong path: %1") << path; + return CLogMessage(CLogCategory::validation()).error("wrong path: %1") << path; } } // namespace } // namespace diff --git a/src/blackmisc/setnetwork.cpp b/src/blackmisc/setnetwork.cpp index 82f3b674d..9b1a485cf 100644 --- a/src/blackmisc/setnetwork.cpp +++ b/src/blackmisc/setnetwork.cpp @@ -183,7 +183,7 @@ namespace BlackMisc changedFlag = this->m_trafficNetworkServers.contains(&CServer::getName, server.getName()); this->m_trafficNetworkServers.removeIf(&CServer::getName, server.getName()); } - return CLogMessage().info(CSettingUtilities::updateMessageCategory(), "Set current server"); + return CLogMessage(CLogCategory::settingsUpdate()).info("Set current server"); } else if (path == CSettingsNetwork::ValueBookingServiceUrl()) { @@ -192,10 +192,10 @@ namespace BlackMisc QString v = value.toString(); changedFlag = (v != this->m_bookingServiceUrl); this->m_bookingServiceUrl = v; - return CLogMessage().info(CSettingUtilities::updateMessageCategory(), "booking URL%1 changed") << (changedFlag ? "" : " not"); + return CLogMessage(CLogCategory::settingsUpdate()).info("booking URL%1 changed") << (changedFlag ? "" : " not"); } } - return CLogMessage().error(CSettingUtilities::validationMessageCategory(), "wrong path: %1") << path; + return CLogMessage(CLogCategory::validation()).error("wrong path: %1") << path; } } // namespace } // namespace diff --git a/src/blacksim/setsimulator.cpp b/src/blacksim/setsimulator.cpp index 3a5d54e14..72135506c 100644 --- a/src/blacksim/setsimulator.cpp +++ b/src/blacksim/setsimulator.cpp @@ -161,9 +161,9 @@ namespace BlackSim CSimulatorInfo v = value.value(); changedFlag = (v != this->m_selectedPlugin); this->m_selectedPlugin = v; - return CLogMessage().info(CSettingUtilities::updateMessageCategory(), "selected driver%1 changed") << (changedFlag ? "" : " not"); + return CLogMessage(CLogCategory::settingsUpdate()).info("selected driver%1 changed") << (changedFlag ? "" : " not"); } - return CLogMessage().error(CSettingUtilities::validationMessageCategory(), "wrong command: %1") << command; + return CLogMessage(CLogCategory::validation()).error("wrong command: %1") << command; } else if (path == CSettingsSimulator::ValueSyncTime()) { @@ -172,9 +172,9 @@ namespace BlackSim bool v = value.value(); changedFlag = (v != this->m_timeSync); this->m_timeSync = v; - return CLogMessage().info(CSettingUtilities::updateMessageCategory(), "time synchronization%1 changed") << (changedFlag ? "" : " not"); + return CLogMessage(CLogCategory::settingsUpdate()).info("time synchronization%1 changed") << (changedFlag ? "" : " not"); } - return CLogMessage().error(CSettingUtilities::validationMessageCategory(), "wrong command: %1") << command; + return CLogMessage(CLogCategory::validation()).error("wrong command: %1") << command; } else if (path == CSettingsSimulator::ValueSyncTimeOffset()) { @@ -183,13 +183,13 @@ namespace BlackSim CTime v = value.value(); changedFlag = (v != this->m_timeSyncOffset); this->m_timeSyncOffset = v; - return CLogMessage().info(CSettingUtilities::updateMessageCategory(), "time synchronization offset%1 changed") << (changedFlag ? "" : " not"); + return CLogMessage(CLogCategory::settingsUpdate()).info("time synchronization offset%1 changed") << (changedFlag ? "" : " not"); } - return CLogMessage().error(CSettingUtilities::validationMessageCategory(), "wrong command: %1") << command; + return CLogMessage(CLogCategory::validation()).error("wrong command: %1") << command; } else { - return CLogMessage().error(CSettingUtilities::validationMessageCategory(), "wrong path: %1") << path; + return CLogMessage(CLogCategory::validation()).error("wrong path: %1") << path; } } } // namespace diff --git a/src/plugins/simulator/fsx/simulator_fsx.cpp b/src/plugins/simulator/fsx/simulator_fsx.cpp index dc44abec3..d2f5fc376 100644 --- a/src/plugins/simulator/fsx/simulator_fsx.cpp +++ b/src/plugins/simulator/fsx/simulator_fsx.cpp @@ -544,7 +544,7 @@ namespace BlackSimPlugin } m_syncDeferredCounter = 5; // allow some time to sync - CLogMessage().info(this, "Synchronized time to UTC: %1") << myTime.toString(); + CLogMessage(this).info("Synchronized time to UTC: %1") << myTime.toString(); } } } diff --git a/src/plugins/simulator/fsx/simulator_fsx_simconnectproc.cpp b/src/plugins/simulator/fsx/simulator_fsx_simconnectproc.cpp index 3ef9e3d7d..2d23e3bf9 100644 --- a/src/plugins/simulator/fsx/simulator_fsx_simconnectproc.cpp +++ b/src/plugins/simulator/fsx/simulator_fsx_simconnectproc.cpp @@ -38,7 +38,7 @@ namespace BlackSimPlugin .arg(event->szApplicationName) .arg(event->dwApplicationVersionMajor).arg(event->dwApplicationVersionMinor).arg(event->dwApplicationBuildMajor).arg(event->dwApplicationBuildMinor) .arg(event->dwSimConnectVersionMajor).arg(event->dwSimConnectVersionMinor).arg(event->dwSimConnectBuildMajor).arg(event->dwSimConnectBuildMinor); - CLogMessage().info(CSimulatorFsx::getMessageCategory(), CProject::systemNameAndVersion()); + CLogMessage(static_cast(nullptr)).info(CProject::systemNameAndVersion()); break; } case SIMCONNECT_RECV_ID_EXCEPTION: diff --git a/src/plugins/simulator/xplane/simulator_xplane.cpp b/src/plugins/simulator/xplane/simulator_xplane.cpp index 11872d19f..bdb5618ae 100644 --- a/src/plugins/simulator/xplane/simulator_xplane.cpp +++ b/src/plugins/simulator/xplane/simulator_xplane.cpp @@ -255,7 +255,7 @@ namespace BlackSimPlugin { if (enable) { - CLogMessage().warning(this, "X-Plane already provides real time synchronization"); + CLogMessage(this).warning("X-Plane already provides real time synchronization"); } } diff --git a/src/swiftgui_standard/mainwindow.cpp b/src/swiftgui_standard/mainwindow.cpp index c0dbde35f..6b30c9d7c 100644 --- a/src/swiftgui_standard/mainwindow.cpp +++ b/src/swiftgui_standard/mainwindow.cpp @@ -251,12 +251,12 @@ void MainWindow::ps_toggleNetworkConnection() if (this->ui->comp_MainInfoArea->getSettingsComponent()->loginStealth()) { mode = INetwork::LoginStealth; - this->ps_displayStatusMessageInGui(CLogMessage().info(this, "login in stealth mode")); + this->ps_displayStatusMessageInGui(CLogMessage(this).info("login in stealth mode")); } else if (this->ui->comp_MainInfoArea->getSettingsComponent()->loginAsObserver()) { mode = INetwork::LoginAsObserver; - this->ps_displayStatusMessageInGui(CLogMessage().info(this, "login in observer mode")); + this->ps_displayStatusMessageInGui(CLogMessage(this).info("login in observer mode")); } CStatusMessage msg = this->getIContextNetwork()->connectToNetwork(static_cast(mode)); this->ps_displayStatusMessageInGui(msg); @@ -278,7 +278,7 @@ void MainWindow::ps_toggleNetworkConnection() bool MainWindow::isContextNetworkAvailableCheck() { if (this->m_contextNetworkAvailable) return true; - this->ps_displayStatusMessageInGui(CLogMessage().error(this, "Network context not available, no updates this time")); + this->ps_displayStatusMessageInGui(CLogMessage(this).error("Network context not available, no updates this time")); return false; } @@ -288,7 +288,7 @@ bool MainWindow::isContextNetworkAvailableCheck() bool MainWindow::isContextAudioAvailableCheck() { if (this->m_contextAudioAvailable) return true; - this->ps_displayStatusMessageInGui(CLogMessage().error(this, "Voice context not available")); + this->ps_displayStatusMessageInGui(CLogMessage(this).error("Voice context not available")); return false; } @@ -500,13 +500,13 @@ void MainWindow::ps_toogleWindowStayOnTop() { flags ^= Qt::WindowStaysOnTopHint; flags |= Qt::WindowStaysOnBottomHint; - this->ps_displayStatusMessageInGui(CLogMessage().info(this, "Window on bottom")); + this->ps_displayStatusMessageInGui(CLogMessage(this).info("Window on bottom")); } else { flags ^= Qt::WindowStaysOnBottomHint; flags |= Qt::WindowStaysOnTopHint; - this->ps_displayStatusMessageInGui(CLogMessage().info(this, "Window on top")); + this->ps_displayStatusMessageInGui(CLogMessage(this).info("Window on top")); } this->setWindowFlags(flags); this->show(); diff --git a/src/swiftgui_standard/mainwindow_init.cpp b/src/swiftgui_standard/mainwindow_init.cpp index 1a3198f2b..563a4a629 100644 --- a/src/swiftgui_standard/mainwindow_init.cpp +++ b/src/swiftgui_standard/mainwindow_init.cpp @@ -236,13 +236,13 @@ void MainWindow::initialDataReads() this->m_coreAvailable = (this->getIContextNetwork()->isUsingImplementingObject() || (this->getIContextApplication()->ping(t) == t)); if (!this->m_coreAvailable) { - this->ps_displayStatusMessageInGui(CLogMessage().error(this, "no initial data read as network context is not available")); + this->ps_displayStatusMessageInGui(CLogMessage(this).error("no initial data read as network context is not available")); return; } this->ui->comp_MainInfoArea->getSettingsComponent()->reloadSettings(); // init read this->ps_reloadOwnAircraft(); // init read, independent of traffic network - this->ps_displayStatusMessageInGui(CLogMessage().info(this, "initial data read")); + this->ps_displayStatusMessageInGui(CLogMessage(this).info("initial data read")); } /* diff --git a/src/swiftgui_standard/mainwindow_menus.cpp b/src/swiftgui_standard/mainwindow_menus.cpp index a13e9f337..d87988560 100644 --- a/src/swiftgui_standard/mainwindow_menus.cpp +++ b/src/swiftgui_standard/mainwindow_menus.cpp @@ -41,7 +41,7 @@ void MainWindow::ps_onMenuClicked() else if (sender == this->ui->menu_ReloadSettings) { this->ui->comp_MainInfoArea->getSettingsComponent()->reloadSettings(); - this->ps_displayStatusMessageInGui(CLogMessage().info(this, "Settings reloaded")); + this->ps_displayStatusMessageInGui(CLogMessage(this).info("Settings reloaded")); } else if (sender == this->ui->menu_FileReloadStyleSheets) { @@ -54,7 +54,7 @@ void MainWindow::ps_onMenuClicked() } else if (sender == this->ui->menu_FileClose) { - this->ps_displayStatusMessageInGui(CLogMessage().info(this, "Closing")); + this->ps_displayStatusMessageInGui(CLogMessage(this).info("Closing")); this->close(); } else if (sender == this->ui->menu_FileSettingsDirectory)