Skip to content

Commit 18793a2

Browse files
committed
Add more logging
1 parent bf8ea4f commit 18793a2

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

src/libsync/httplogger.cpp

+13-7
Original file line numberDiff line numberDiff line change
@@ -144,21 +144,26 @@ void HttpLogger::logRequest(QNetworkReply *reply, QNetworkAccessManager::Operati
144144
return;
145145
}
146146

147+
const auto logError = [reply, operation]() {
148+
auto url = reply->request().url();
149+
qCInfo(lcNetworkHttp).noquote().nospace() << "An error occurred for " << url.toDisplayString() << ": " << reply->errorString() << " (" << reply->error()
150+
<< ", " << operation << ")";
151+
};
152+
147153
auto ctx = std::make_unique<HttpContext>(reply->request());
148154

149155
// device should still exist, lets still use a qpointer to ensure we have valid data
150-
const auto logSend = [ctx = ctx.get(), operation, reply, device = QPointer<QIODevice>(device), deviceRaw = device](bool cached = false) {
156+
const auto logSend = [ctx = ctx.get(), operation, reply, device = QPointer<QIODevice>(device), deviceRaw = device, logError](bool cached = false) {
151157
Q_ASSERT(!deviceRaw || device);
152158
if (!ctx->send) {
153159
ctx->send = true;
154160
ctx->timer.reset();
155-
} else {
161+
} else if (ctx->lastUrl != reply->url()) {
156162
// this is a redirect
157-
if (ctx->lastUrl != reply->url()) {
158-
ctx->addRedirect(reply->url());
159-
} else {
160-
Q_UNREACHABLE();
161-
}
163+
ctx->addRedirect(reply->url());
164+
} else {
165+
// Probably an error (time-out?).
166+
logError();
162167
}
163168

164169
const auto request = reply->request();
@@ -169,6 +174,7 @@ void HttpLogger::logRequest(QNetworkReply *reply, QNetworkAccessManager::Operati
169174
logHttp(requestVerb(operation, request), ctx, std::move(header), device, cached);
170175
};
171176
QObject::connect(reply, &QNetworkReply::requestSent, reply, logSend, Qt::DirectConnection);
177+
QObject::connect(reply, &QNetworkReply::errorOccurred, reply, logError, Qt::DirectConnection);
172178

173179

174180
QObject::connect(

src/libsync/syncengine.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -819,7 +819,7 @@ void SyncEngine::abort(const QString &reason)
819819
disconnect(_discoveryPhase.get(), nullptr, this, nullptr);
820820
}
821821
if (aborting) {
822-
qCInfo(lcEngine) << "Aborting sync";
822+
qCInfo(lcEngine) << "Aborting sync, stated reason:" << reason;
823823
if (!_goingDown) {
824824
Q_EMIT syncError(tr("Aborted due to %1").arg(reason));
825825
}

0 commit comments

Comments
 (0)