Ref T149, use URL log to log network access in threaded reader classes

* added getFromNetworkAndLog
* adjusted DB reader
* adjusted other readers
This commit is contained in:
Klaus Basan
2017-09-10 23:35:15 +02:00
committed by Mathew Sutcliffe
parent 1c57ce87a2
commit b9760b4c60
11 changed files with 57 additions and 17 deletions

View File

@@ -69,7 +69,7 @@ namespace BlackCore
Q_ASSERT_X(sApp, Q_FUNC_INFO, "No application");
const QUrl url(sApp->getGlobalSetup().getVatsimBookingsUrl());
if (url.isEmpty()) { return; }
sApp->getFromNetwork(url, { this, &CVatsimBookingReader::ps_parseBookings});
this->getFromNetworkAndLog(url, { this, &CVatsimBookingReader::ps_parseBookings});
}
void CVatsimBookingReader::ps_parseBookings(QNetworkReply *nwReplyPtr)
@@ -77,7 +77,6 @@ namespace BlackCore
// wrap pointer, make sure any exit cleans up reply
// required to use delete later as object is created in a different thread
QScopedPointer<QNetworkReply, QScopedPointerDeleteLater> nwReply(nwReplyPtr);
this->threadAssertCheck();
// Worker thread, make sure to write no members here od do it threadsafe
@@ -87,6 +86,7 @@ namespace BlackCore
return; // stop, terminate straight away, ending thread
}
this->logNetworkReplyReceived(nwReplyPtr);
if (nwReply->error() == QNetworkReply::NoError)
{
static const QString timestampFormat("yyyy-MM-dd HH:mm:ss");

View File

@@ -192,7 +192,7 @@ namespace BlackCore
CFailoverUrlList urls(sApp->getVatsimDataFileUrls());
const QUrl url(urls.obtainNextWorkingUrl(true));
if (url.isEmpty()) { return; }
sApp->getFromNetwork(url, { this, &CVatsimDataFileReader::ps_parseVatsimFile});
this->getFromNetworkAndLog(url, { this, &CVatsimDataFileReader::ps_parseVatsimFile});
}
void CVatsimDataFileReader::ps_parseVatsimFile(QNetworkReply *nwReplyPtr)
@@ -200,15 +200,16 @@ namespace BlackCore
// wrap pointer, make sure any exit cleans up reply
// required to use delete later as object is created in a different thread
QScopedPointer<QNetworkReply, QScopedPointerDeleteLater> nwReply(nwReplyPtr);
this->threadAssertCheck();
// Worker thread, make sure to write only synced here!
this->threadAssertCheck();
if (!this->doWorkCheck())
{
CLogMessage(this).info("Terminated VATSIM file parsing process");
return; // stop, terminate straight away, ending thread
}
this->logNetworkReplyReceived(nwReplyPtr);
QStringList illegalIcaoCodes;
if (nwReply->error() == QNetworkReply::NoError)
{

View File

@@ -82,7 +82,7 @@ namespace BlackCore
const CUrl url(urls.obtainNextWorkingUrl(true));
if (url.isEmpty()) { return; }
Q_ASSERT_X(sApp, Q_FUNC_INFO, "No Application");
sApp->getFromNetwork(url.withAppendedQuery("id=all"), { this, &CVatsimMetarReader::decodeMetars});
this->getFromNetworkAndLog(url.withAppendedQuery("id=all"), { this, &CVatsimMetarReader::decodeMetars});
}
void CVatsimMetarReader::decodeMetars(QNetworkReply *nwReplyPtr)
@@ -99,6 +99,7 @@ namespace BlackCore
return; // stop, terminate straight away, ending thread
}
this->logNetworkReplyReceived(nwReplyPtr);
if (nwReply->error() == QNetworkReply::NoError)
{
QString metarData = nwReply->readAll();
@@ -135,7 +136,7 @@ namespace BlackCore
else
{
// network error
CLogMessage(this).warning("Reading METARs failed %1 %2") << nwReply->errorString() << nwReply->url().toString();
CLogMessage(this).warning("Reading METARs failed '%1' for '%2'") << nwReply->errorString() << nwReply->url().toString();
nwReply->abort();
emit dataRead(CEntityFlags::MetarEntity, CEntityFlags::ReadFailed, 0);
}

View File

@@ -72,7 +72,7 @@ namespace BlackCore
CFailoverUrlList urls(sApp->getGlobalSetup().getVatsimStatusFileUrls());
const CUrl url(urls.obtainNextWorkingUrl(true)); // random working URL
if (url.isEmpty()) { return; }
sApp->getFromNetwork(url, { this, &CVatsimStatusFileReader::ps_parseVatsimFile});
this->getFromNetworkAndLog(url, { this, &CVatsimStatusFileReader::ps_parseVatsimFile});
}
void CVatsimStatusFileReader::ps_parseVatsimFile(QNetworkReply *nwReplyPtr)
@@ -90,6 +90,7 @@ namespace BlackCore
return; // stop, terminate straight away, ending thread
}
this->logNetworkReplyReceived(nwReplyPtr);
if (nwReply->error() == QNetworkReply::NoError)
{
const QString dataFileData = nwReply->readAll();