diff options
author | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-03-28 11:29:41 +0900 |
---|---|---|
committer | Kitsune Ral <Kitsune-Ral@users.sf.net> | 2018-03-28 11:29:41 +0900 |
commit | 503957c86a84f1be190719a17984df1bb1267658 (patch) | |
tree | 228619c07cdc2168d43c88fa68f1a644a6298782 /jobs/basejob.cpp | |
parent | 0f85d696c595fddb47ffa4eaec305d93e2ac8ab0 (diff) | |
download | libquotient-503957c86a84f1be190719a17984df1bb1267658.tar.gz libquotient-503957c86a84f1be190719a17984df1bb1267658.zip |
BaseJob: small refactoring and cleanup in logging code
Diffstat (limited to 'jobs/basejob.cpp')
-rw-r--r-- | jobs/basejob.cpp | 17 |
1 files changed, 3 insertions, 14 deletions
diff --git a/jobs/basejob.cpp b/jobs/basejob.cpp index eb250723..5198c45c 100644 --- a/jobs/basejob.cpp +++ b/jobs/basejob.cpp @@ -84,18 +84,6 @@ class BaseJob::Private LoggingCategory logCat = JOBS; }; -inline QDebug operator<<(QDebug dbg, const BaseJob* j) -{ - return dbg << j->objectName(); -} - -QDebug QMatrixClient::operator<<(QDebug dbg, const BaseJob::Status& s) -{ - QRegularExpression filter { "(access_token)(=|: )[-_A-Za-z0-9]+" }; - return dbg << s.code << ':' - << QString(s.message).replace(filter, "\\1 HIDDEN"); -} - BaseJob::BaseJob(HttpVerb verb, const QString& name, const QString& endpoint, bool needsToken) : BaseJob(verb, name, endpoint, Query { }, Data { }, needsToken) { } @@ -319,7 +307,7 @@ BaseJob::Status BaseJob::checkReply(QNetworkReply* reply) const if (checkContentType(reply->rawHeader("Content-Type"), d->expectedContentTypes)) return NoError; - else + else // A warning in the logs might be more proper instead return { IncorrectResponseError, "Incorrect content type of the response" }; @@ -383,7 +371,7 @@ void BaseJob::finishJob() const auto retryInterval = error() == TimeoutError ? 0 : getNextRetryInterval(); ++d->retriesTaken; - qCWarning(d->logCat) << this << "will take retry" << d->retriesTaken + qCWarning(d->logCat) << this << "will retry" << d->retriesTaken << "in" << retryInterval/1000 << "s"; d->retryTimer.start(retryInterval); emit retryScheduled(d->retriesTaken, retryInterval); @@ -456,6 +444,7 @@ void BaseJob::setStatus(Status s) void BaseJob::setStatus(int code, QString message) { + message.replace(d->connection->accessToken(), "(REDACTED)"); setStatus({ code, message }); } |