Skip to content

Commit

Permalink
Merge pull request #1519 from syyyr/use-more-of-the-logger
Browse files Browse the repository at this point in the history
OsmTileDownloader: Use logger
  • Loading branch information
Framstag authored Oct 23, 2023
2 parents 8bda4de + 75194bc commit d82b2ae
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions libosmscout-client-qt/src/osmscoutclientqt/OsmTileDownloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/

#include <QDebug>
#include <QThread>
#if QT_VERSION >= QT_VERSION_CHECK(5, 10, 0) /* For compatibility with QT 5.6 */
#include <QRandomGenerator>
Expand Down Expand Up @@ -80,7 +79,7 @@ void OsmTileDownloader::download(uint32_t zoomLevel, uint32_t x, uint32_t y)
QString server = QString::fromStdString(servers[serverNumber % servers.size()]);

QUrl tileUrl(server.arg(zoomLevel).arg(x).arg(y));
qDebug() << "Download tile" << tileUrl << "(current thread:" << QThread::currentThread() << ")";
osmscout::log.Debug() << "Download tile" << tileUrl.toString().toStdString() << "(current thread:" << QThread::currentThread() << ")";

TileCacheKey key = {zoomLevel, x, y};

Expand All @@ -103,7 +102,7 @@ void OsmTileDownloader::fileDownloaded(const TileCacheKey &key, QNetworkReply *r
QUrl url = reply->url();

if (reply->error() != QNetworkReply::NoError){
qWarning() << "Downloading" << url << "failed with" << reply->errorString();
osmscout::log.Warn() << "Downloading" << url.toString().toStdString() << "failed with" << reply->errorString().toStdString();
#if QT_VERSION < QT_VERSION_CHECK(5, 10, 0) /* For compatibility with QT 5.6 */
serverNumber = qrand(); // try another server for future requests
#else
Expand All @@ -115,10 +114,11 @@ void OsmTileDownloader::fileDownloaded(const TileCacheKey &key, QNetworkReply *r

QImage image;
if (image.loadFromData(downloadedData, Q_NULLPTR)){
qDebug() << "Downloaded tile " << url << " (current thread: " << QThread::currentThread() << ")";
osmscout::log.Debug() << "Downloaded tile " << url.toString().toStdString() << " (current thread: " << QThread::currentThread() << ")";

emit downloaded(key.zoomLevel, key.xtile, key.ytile, image, downloadedData);
}else{
qWarning() << "Failed to load image data from " << url;
osmscout::log.Warn() << "Failed to load image data from " << url.toString().toStdString();
emit failed(key.zoomLevel, key.xtile, key.ytile, false);
}
}
Expand Down

0 comments on commit d82b2ae

Please sign in to comment.