comparison framework/VersionTester.cpp @ 786:1089d65c585d tip

Divert some debug output away from stderr
author Chris Cannam
date Fri, 14 Aug 2020 10:46:44 +0100
parents beefce638f91
children
comparison
equal deleted inserted replaced
785:e136dd3bb5c6 786:1089d65c585d
32 m_reply(nullptr), 32 m_reply(nullptr),
33 m_httpFailed(false), 33 m_httpFailed(false),
34 m_nm(new QNetworkAccessManager) 34 m_nm(new QNetworkAccessManager)
35 { 35 {
36 QUrl url(QString("http://%1/%2").arg(hostname).arg(versionFilePath)); 36 QUrl url(QString("http://%1/%2").arg(hostname).arg(versionFilePath));
37 SVCERR << "VersionTester: URL is " << url << endl; 37 SVDEBUG << "VersionTester: URL is " << url << endl;
38 m_reply = m_nm->get(QNetworkRequest(url)); 38 m_reply = m_nm->get(QNetworkRequest(url));
39 connect(m_reply, SIGNAL(error(QNetworkReply::NetworkError)), 39 connect(m_reply, SIGNAL(error(QNetworkReply::NetworkError)),
40 this, SLOT(error(QNetworkReply::NetworkError))); 40 this, SLOT(error(QNetworkReply::NetworkError)));
41 connect(m_reply, SIGNAL(finished()), this, SLOT(finished())); 41 connect(m_reply, SIGNAL(finished()), this, SLOT(finished()));
42 } 42 }
80 } 80 }
81 81
82 void 82 void
83 VersionTester::error(QNetworkReply::NetworkError) 83 VersionTester::error(QNetworkReply::NetworkError)
84 { 84 {
85 SVCERR << "VersionTester: error: " << m_reply->errorString() << endl; 85 SVDEBUG << "VersionTester: error: " << m_reply->errorString() << endl;
86 m_httpFailed = true; 86 m_httpFailed = true;
87 } 87 }
88 88
89 void 89 void
90 VersionTester::finished() 90 VersionTester::finished()
95 r->deleteLater(); 95 r->deleteLater();
96 if (m_httpFailed) return; 96 if (m_httpFailed) return;
97 97
98 int status = r->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt(); 98 int status = r->attribute(QNetworkRequest::HttpStatusCodeAttribute).toInt();
99 if (status / 100 != 2) { 99 if (status / 100 != 2) {
100 SVCERR << "VersionTester: error: http status = " << status << endl; 100 SVDEBUG << "VersionTester: error: http status = " << status << endl;
101 return; 101 return;
102 } 102 }
103 103
104 QByteArray responseData = r->readAll(); 104 QByteArray responseData = r->readAll();
105 QString str = QString::fromUtf8(responseData.data()); 105 QString str = QString::fromUtf8(responseData.data());
106 QStringList lines = str.split('\n', QString::SkipEmptyParts); 106 QStringList lines = str.split('\n', QString::SkipEmptyParts);
107 if (lines.empty()) return; 107 if (lines.empty()) return;
108 108
109 QString latestVersion = lines[0]; 109 QString latestVersion = lines[0];
110 SVCERR << "Comparing current version \"" << m_myVersion << "\" with latest version \"" << latestVersion << "\"" << endl; 110 SVDEBUG << "Comparing current version \"" << m_myVersion << "\" with latest version \"" << latestVersion << "\"" << endl;
111 if (isVersionNewerThan(latestVersion, m_myVersion)) { 111 if (isVersionNewerThan(latestVersion, m_myVersion)) {
112 SVCERR << "Latest version \"" << latestVersion << "\" is newer than current version \"" << m_myVersion << "\"" << endl; 112 SVDEBUG << "Latest version \"" << latestVersion << "\" is newer than current version \"" << m_myVersion << "\"" << endl;
113 emit newerVersionAvailable(latestVersion); 113 emit newerVersionAvailable(latestVersion);
114 } 114 }
115 } 115 }
116 116
117 117