UI: Tasks: Add debug outputs

This commit is contained in:
Nodir Temirkhodjaev 2024-02-25 08:52:42 +03:00
parent 412f42e5e6
commit 9161639eaa
5 changed files with 49 additions and 14 deletions

View File

@ -152,11 +152,10 @@ void TaskInfo::setupTaskWorker()
void TaskInfo::runTaskWorker()
{
if (aborted() || !taskWorker())
return;
if (taskWorker()) {
taskWorker()->run();
}
}
void TaskInfo::abortTask()
{

View File

@ -1,10 +1,18 @@
#include "taskinfoapppurger.h"
#include <QLoggingCategory>
#include <conf/confappmanager.h>
#include <util/ioc/ioccontainer.h>
#include "taskmanager.h"
namespace {
const QLoggingCategory LC("task.appPurger");
}
TaskInfoAppPurger::TaskInfoAppPurger(TaskManager &taskManager) :
TaskInfo(AppPurger, taskManager) { }
@ -13,5 +21,7 @@ void TaskInfoAppPurger::runTaskWorker()
// TODO: Use worker to run in a separate thread to not block the UI
const bool ok = IoC<ConfAppManager>()->purgeApps();
qCDebug(LC) << "Purged:" << ok;
handleFinished(ok);
}

View File

@ -1,6 +1,7 @@
#include "taskinfoupdatechecker.h"
#include <QDataStream>
#include <QLoggingCategory>
#include <QVersionNumber>
#include <fort_version.h>
@ -8,7 +9,13 @@
#include "taskmanager.h"
#include "taskupdatechecker.h"
#define TASK_INFO_VERSION 2
namespace {
const QLoggingCategory LC("task.updateChecker");
constexpr int TASK_INFO_VERSION = 2;
}
TaskInfoUpdateChecker::TaskInfoUpdateChecker(TaskManager &taskManager) :
TaskInfo(UpdateChecker, taskManager)
@ -71,13 +78,17 @@ TaskUpdateChecker *TaskInfoUpdateChecker::updateChecker() const
bool TaskInfoUpdateChecker::processResult(bool success)
{
if (!success)
if (!success) {
qCDebug(LC) << "Failed";
return false;
}
const auto worker = updateChecker();
if (m_version == worker->version())
if (m_version == worker->version()) {
qCDebug(LC) << "Same version";
return false;
}
m_version = worker->version();
m_downloadUrl = worker->downloadUrl();
@ -86,7 +97,11 @@ bool TaskInfoUpdateChecker::processResult(bool success)
emitAppVersionUpdated();
if (isNewVersion()) {
qCDebug(LC) << "New version found:" << m_version;
emit taskManager()->appVersionDownloaded(m_version);
} else {
qCDebug(LC) << "Old version found:" << m_version;
}
return true;

View File

@ -1,6 +1,7 @@
#include "taskinfozonedownloader.h"
#include <QDir>
#include <QLoggingCategory>
#include <conf/confzonemanager.h>
#include <fortsettings.h>
@ -14,6 +15,12 @@
#include "taskmanager.h"
#include "taskzonedownloader.h"
namespace {
const QLoggingCategory LC("task.zoneDownloader");
}
TaskInfoZoneDownloader::TaskInfoZoneDownloader(TaskManager &taskManager) :
TaskInfo(ZoneDownloader, taskManager)
{
@ -31,8 +38,12 @@ ZoneListModel *TaskInfoZoneDownloader::zoneListModel() const
bool TaskInfoZoneDownloader::processResult(bool success)
{
if (!success)
if (!success) {
qCDebug(LC) << "No updates";
return false;
}
qCDebug(LC) << "Updated:" << m_zoneNames;
emit taskManager()->zonesDownloaded(m_zoneNames);

View File

@ -7,7 +7,7 @@
#define DOWNLOAD_MAXSIZE (8 * 1024 * 1024)
namespace {
const QLoggingCategory LC("util.net.netDownloader");
const QLoggingCategory LC("util.net.downloader");
}
NetDownloader::NetDownloader(QObject *parent) :
@ -16,7 +16,7 @@ NetDownloader::NetDownloader(QObject *parent) :
m_downloadTimer.setInterval(DOWNLOAD_TIMEOUT);
connect(&m_downloadTimer, &QTimer::timeout, this, [&] {
qCDebug(LC) << "NetDownloader: Error: Download timed out";
qCDebug(LC) << "Error: Download timed out";
finish();
});
@ -31,7 +31,7 @@ QByteArray NetDownloader::takeBuffer()
void NetDownloader::start()
{
qCDebug(LC) << "NetDownloader: Start:" << url() << data();
qCDebug(LC) << "Fetch:" << url() << data();
m_started = true;
m_aborted = false;
@ -85,7 +85,7 @@ void NetDownloader::onDownloadProgress(qint64 bytesReceived, qint64 /*bytesTotal
m_buffer.append(data);
if (m_buffer.size() >= DOWNLOAD_MAXSIZE) {
qCWarning(LC) << "NetDownloader: Error: Too big file";
qCWarning(LC) << "Error: Too big file";
finish();
}
}
@ -102,7 +102,7 @@ void NetDownloader::onErrorOccurred(QNetworkReply::NetworkError error)
if (m_aborted)
return;
qCWarning(LC) << "NetDownloader: Error:" << error << m_reply->errorString();
qCWarning(LC) << "Error:" << error << m_reply->errorString();
finish();
}
@ -113,7 +113,7 @@ void NetDownloader::onSslErrors(const QList<QSslError> &errors)
return;
for (const QSslError &error : errors) {
qCWarning(LC) << "NetDownloader: SSL Error:" << error.errorString();
qCWarning(LC) << "SSL Error:" << error.errorString();
}
finish();