123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- #ifndef CLOGTRACK_H
- #define CLOGTRACK_H
- #include <list>
- #include <QString>
- #include <map>
- #include <thread>
- #include <mutex>
- #include <QWidget>
- #include "CHttpClient.h"
- namespace LOG_CONSTANT_DEF
- {
- const char* const LOG_API_VERSION = "0.6.0";
- const char* const X_LOG_APIVERSION = "x-log-apiversion";
- const char* const X_LOG_BODYRAWSIZE = "x-log-bodyrawsize";
- const char* const SOURCE = "__source__";
- const char* const WIN = "win";
- const char* const LOGS = "__logs__";
- };
- struct OC
- {
- OC() { oc = std::make_shared<std::once_flag >();}
- std::shared_ptr<std::once_flag> oc;
- int a;
- };
- class CLogInfo
- {
- public:
- QString sKey;
- QString sValue;
- CLogInfo()
- {
- sKey = "";
- sValue = "";
- }
- };
- class CLogData
- {
- public:
- CLogData();
- ~CLogData();
- QString genLogJson();
- void pushLog(QString sKey, QString sValue);
- private:
- std::vector<CLogInfo> m_LogList;
- };
- class CLogTrack : public QObject
- {
- Q_OBJECT
- public:
- CLogTrack(QString sProjectName, QString sEndpoint, QString sLogstore);
- ~CLogTrack();
- void putLog(CLogData log);
- signals:
- // void logFaild(OC oc);
- private:
- void threadProc();
- std::thread m_thread;
- bool m_bIsRun;
- std::list<CLogData> m_LogList;
- std::mutex m_logMutex;
- CHttpClient m_httpClient;
- QString m_sUrl;
- };
- extern std::shared_ptr<CLogTrack> g_logPtr;
- //class base : public QWidget
- //{
- // Q_OBJECT
- //public:
- // base(QWidget *parent = nullptr) : QWidget(parent)
- // {
- // qRegisterMetaType<OC>("OC");
- // connect(g_logPtr.get(), &CLogTrack::logFaild, this, &base::logFaild);
- // }
- //private slots:
- // virtual void logFaild(OC oc)
- // {
- // std::call_once(*oc.oc.get(), []() {
- // });
- // }
- //};
- #endif // CLOGTRACK_H
|