#include "AppLogger.h" #include #include #include "dao/AppLogDAO.h" #include "db/AppLogEntry.h" #include "net/NetworkService.h" NetworkService *AppLogger::s_networkService = nullptr; void AppLogger::setNetworkService(NetworkService *service) { s_networkService = service; } void AppLogger::log(const QString &source, const QString &deviceId, const QString &message, const QByteArray &screenshot, const QString &event) { AppLogEntry entry; entry.source = source; entry.deviceId = deviceId; entry.message = message; entry.screenshot = screenshot; entry.timestamp = QDateTime::currentDateTimeUtc(); AppLogDAO::insert(entry); if (s_networkService) { QMetaObject::invokeMethod(s_networkService, "postMonitoringLog", Qt::QueuedConnection, Q_ARG(QString, QStringLiteral("ERROR")), Q_ARG(QString, event.isEmpty() ? source : event), Q_ARG(QString, message), Q_ARG(QByteArray, screenshot)); } }