mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-03 15:45:46 +08:00
refs #336 Using the new CLogMessage syntax to log messages.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -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
|
||||
{
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -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<BlackSound::CNotificationSounds::Notification>(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<double>(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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
|
||||
@@ -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");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
@@ -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";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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();
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user