File indexing completed on 2024-12-01 05:07:46
0001 #include "common/uploadlogtoserver.h" 0002 #include <QCoreApplication> 0003 #include <QThread> 0004 #include <common/remotelogcontroller.h> 0005 0006 RemoteLogController::RemoteLogController() {} 0007 void RemoteLogController::addLog(const QString& msg, const QString& level, const QString& category, 0008 const QString& timestamp) 0009 { 0010 common::Log tm= {category, msg, timestamp, level}; 0011 m_temporyData.push_back(tm); 0012 if(m_temporyData.size() == m_numberPackages) 0013 sendOffMessage(); 0014 } 0015 0016 void RemoteLogController::sendOffMessage() 0017 { 0018 QThread* thread= new QThread(); 0019 LogUploader* uploader= new LogUploader(); 0020 uploader->setAppId(m_appId); 0021 uploader->setLogs(m_temporyData); 0022 uploader->setUuid(m_localUuid); 0023 uploader->setVersion(QCoreApplication::applicationVersion()); 0024 0025 uploader->moveToThread(thread); 0026 0027 connect(uploader, &LogUploader::finished, thread, &QThread::quit); 0028 connect(thread, &QThread::finished, uploader, &LogUploader::deleteLater); 0029 connect(thread, &QThread::started, uploader, &LogUploader::uploadLog); 0030 connect(uploader, &LogUploader::destroyed, thread, &QThread::deleteLater); 0031 0032 thread->start(); 0033 0034 m_temporyData.clear(); 0035 } 0036 0037 int RemoteLogController::appId() const 0038 { 0039 return m_appId; 0040 } 0041 0042 void RemoteLogController::setAppId(int appId) 0043 { 0044 m_appId= appId; 0045 } 0046 0047 QString RemoteLogController::localUuid() const 0048 { 0049 return m_localUuid; 0050 } 0051 0052 void RemoteLogController::setLocalUuid(const QString& localUuid) 0053 { 0054 m_localUuid= localUuid; 0055 }