mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-03-22 14:55:36 +08:00
Log info/warning about METAR URL
This commit is contained in:
committed by
Mat Sutcliffe
parent
0e3cba35ff
commit
1d75b5fac7
@@ -1175,6 +1175,7 @@ namespace BlackCore
|
||||
CMetar CContextNetwork::getMetarForAirport(const CAirportIcaoCode &airportIcaoCode) const
|
||||
{
|
||||
if (this->isDebugEnabled()) { CLogMessage(this, CLogCategory::contextSlot()).debug() << Q_FUNC_INFO << airportIcaoCode; }
|
||||
if (!sApp || !sApp->getWebDataServices()) { return {}; }
|
||||
return sApp->getWebDataServices()->getMetarForAirport(airportIcaoCode);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,6 +29,7 @@
|
||||
#include <QtGlobal>
|
||||
|
||||
using namespace BlackMisc;
|
||||
using namespace BlackMisc::Aviation;
|
||||
using namespace BlackMisc::Network;
|
||||
using namespace BlackMisc::Weather;
|
||||
using namespace BlackCore::Data;
|
||||
@@ -60,7 +61,7 @@ namespace BlackCore
|
||||
return m_metars;
|
||||
}
|
||||
|
||||
CMetar CVatsimMetarReader::getMetarForAirport(const Aviation::CAirportIcaoCode &icao) const
|
||||
CMetar CVatsimMetarReader::getMetarForAirport(const CAirportIcaoCode &icao) const
|
||||
{
|
||||
QReadLocker l(&m_lock);
|
||||
return m_metars.getMetarForAirport(icao);
|
||||
@@ -108,14 +109,20 @@ namespace BlackCore
|
||||
}
|
||||
|
||||
this->logNetworkReplyReceived(nwReplyPtr);
|
||||
const QString metarUrl = nwReply->url().toString();
|
||||
if (nwReply->error() == QNetworkReply::NoError)
|
||||
{
|
||||
QString metarData = nwReply->readAll();
|
||||
nwReply->close(); // close asap
|
||||
|
||||
if (metarData.isEmpty()) // Quick check by hash
|
||||
{
|
||||
CLogMessage(this).warning(u"No METAR data from '%1', skipped") << metarUrl;
|
||||
return;
|
||||
}
|
||||
if (!this->didContentChange(metarData)) // Quick check by hash
|
||||
{
|
||||
CLogMessage(this).info(u"METAR file has same content, skipped");
|
||||
CLogMessage(this).info(u"METAR file from '%1' has same content, skipped") << metarUrl;
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -146,7 +153,7 @@ namespace BlackCore
|
||||
else
|
||||
{
|
||||
// network error
|
||||
CLogMessage(this).warning(u"Reading METARs failed '%1' for '%2'") << nwReply->errorString() << nwReply->url().toString();
|
||||
CLogMessage(this).warning(u"Reading METARs failed '%1' for '%2'") << nwReply->errorString() << metarUrl;
|
||||
nwReply->abort();
|
||||
emit this->dataRead(CEntityFlags::MetarEntity, CEntityFlags::ReadFailed, 0);
|
||||
}
|
||||
@@ -154,8 +161,8 @@ namespace BlackCore
|
||||
|
||||
void CVatsimMetarReader::reloadSettings()
|
||||
{
|
||||
CReaderSettings s = m_settings.get();
|
||||
setInitialAndPeriodicTime(s.getInitialTime().toMs(), s.getPeriodicTime().toMs());
|
||||
const CReaderSettings s = m_settings.get();
|
||||
this->setInitialAndPeriodicTime(s.getInitialTime().toMs(), s.getPeriodicTime().toMs());
|
||||
}
|
||||
} // ns
|
||||
} // ns
|
||||
|
||||
Reference in New Issue
Block a user