Refactor TaskDumpRecorder to adjust LogArchiveSender invocation for improved dump and log dispatch sequencing, and remove redundant usages in EventHandler.
This commit is contained in:
parent
0045c37d64
commit
9da2a6fc52
@ -220,9 +220,6 @@ void TaskDumpRecorder::finishInternal(const QString &errorMessage) {
|
||||
qWarning() << "[TaskDumpRecorder] task failed:" << errorMessage
|
||||
<< "folder:" << m_folder;
|
||||
|
||||
// application.log + БД (с WAL/SHM) уходят отдельным архивом через готовый sender.
|
||||
LogArchiveSender::dispatch(QStringLiteral("TASK_ERROR"));
|
||||
|
||||
// Финальный скриншот текущего экрана
|
||||
if (!m_adbDeviceIdRaw.isEmpty()) {
|
||||
const QByteArray png = AdbUtils::captureScreenshotBytes(m_adbDeviceIdRaw);
|
||||
@ -282,24 +279,29 @@ void TaskDumpRecorder::finishInternal(const QString &errorMessage) {
|
||||
QFile::remove(archivePath);
|
||||
|
||||
NetworkService *svc = networkServiceRef().data();
|
||||
if (!svc) {
|
||||
if (svc) {
|
||||
qDebug() << "[TaskDumpRecorder] dispatching dump to NetworkService"
|
||||
<< "archive.size=" << archiveBytes.size()
|
||||
<< "image.size=" << finalScreenshot.size()
|
||||
<< "text.size=" << text.size();
|
||||
const bool dispatched = QMetaObject::invokeMethod(svc, "postMonitoringDump",
|
||||
Qt::QueuedConnection,
|
||||
Q_ARG(QString, text),
|
||||
Q_ARG(QByteArray, archiveBytes),
|
||||
Q_ARG(QByteArray, finalScreenshot));
|
||||
if (!dispatched) {
|
||||
qCritical() << "[TaskDumpRecorder] invokeMethod(postMonitoringDump) FAILED — "
|
||||
"slot not found or wrong signature for" << folder;
|
||||
}
|
||||
} else {
|
||||
qWarning() << "[TaskDumpRecorder] no NetworkService — dump dropped for" << folder
|
||||
<< "(setNetworkService was not called at app startup?)";
|
||||
return;
|
||||
}
|
||||
qDebug() << "[TaskDumpRecorder] dispatching dump to NetworkService"
|
||||
<< "archive.size=" << archiveBytes.size()
|
||||
<< "image.size=" << finalScreenshot.size()
|
||||
<< "text.size=" << text.size();
|
||||
const bool dispatched = QMetaObject::invokeMethod(svc, "postMonitoringDump",
|
||||
Qt::QueuedConnection,
|
||||
Q_ARG(QString, text),
|
||||
Q_ARG(QByteArray, archiveBytes),
|
||||
Q_ARG(QByteArray, finalScreenshot));
|
||||
if (!dispatched) {
|
||||
qCritical() << "[TaskDumpRecorder] invokeMethod(postMonitoringDump) FAILED — "
|
||||
"slot not found or wrong signature for" << folder;
|
||||
}
|
||||
|
||||
// Следом — application.log + БД (+ WAL/SHM) отдельным архивом.
|
||||
// Запускаем уже ПОСЛЕ того, как task-дамп поставлен в очередь
|
||||
// отправки, чтобы порядок прихода на relay был "дамп → логи".
|
||||
LogArchiveSender::dispatch(QStringLiteral("TASK_ERROR"));
|
||||
});
|
||||
QObject::connect(bg, &QThread::finished, bg, &QObject::deleteLater);
|
||||
bg->start();
|
||||
|
||||
@ -16,7 +16,6 @@
|
||||
#include "dao/EventDAO.h"
|
||||
#include "dao/SettingsDAO.h"
|
||||
#include "dao/TransactionDAO.h"
|
||||
#include "LogArchiveSender.h"
|
||||
#include "db/BankProfileInfo.h"
|
||||
#include "adb/AdbUtils.h"
|
||||
#include "dao/GeneralLogDAO.h"
|
||||
@ -224,8 +223,8 @@ static void sendTaskError(const QString &type, const QString &materialId, const
|
||||
sendMonitoringLog("error", "task_error", message, screenshot, eventId);
|
||||
}
|
||||
|
||||
// Следом ушлём application.log + БД (с WAL/SHM) одним архивом.
|
||||
LogArchiveSender::dispatch(QStringLiteral("TASK_ERROR"), eventId);
|
||||
// application.log + БД отправляются из TaskDumpRecorder::finishInternal,
|
||||
// чтобы покрывать также non-event-driven задачи (login flow и т.п.).
|
||||
}
|
||||
|
||||
static void sendMonitoringLog(const QString &type, const QString &event, const QString &message,
|
||||
|
||||
Loading…
Reference in New Issue
Block a user