From e87f12d4a47cd5bc5cfbc74d278091732f2750ff Mon Sep 17 00:00:00 2001 From: "littletux89@gmail.com" <littletux89@gmail.com> Date: Fri, 17 May 2019 23:36:08 +0300 Subject: [PATCH] [+] Added class reading log nodes. --- KelvinDashboardService/DapLogReader.cpp | 25 +++++++++++++++++++ KelvinDashboardService/DapLogReader.h | 23 +++++++++++++++++ .../KelvinDashboardService.pro | 6 +++-- KelvinDashboardService/main.cpp | 8 ++++-- 4 files changed, 58 insertions(+), 4 deletions(-) create mode 100644 KelvinDashboardService/DapLogReader.cpp create mode 100644 KelvinDashboardService/DapLogReader.h diff --git a/KelvinDashboardService/DapLogReader.cpp b/KelvinDashboardService/DapLogReader.cpp new file mode 100644 index 000000000..83a97f46f --- /dev/null +++ b/KelvinDashboardService/DapLogReader.cpp @@ -0,0 +1,25 @@ +#include "DapLogReader.h" + +DapLogReader::DapLogReader(QObject *parent) : QObject(parent) +{ + +} + +QList<QString> DapLogReader::request(int aiTimeStamp, int aiRowCount) +{ + QList<QString> str; + QByteArray result; + QProcess process; + process.start(QString("%1 print_log ts_after %2 limit %3").arg("/home/andrey/Demlabs/build-kelvin-node/kelvin-node-cli").arg(aiTimeStamp).arg(aiRowCount)); + process.waitForFinished(-1); + result = process.readAll(); + + if(result.isEmpty()) + qDebug() << "FALSE"; + else + { + qDebug() << "TRUE"; + qDebug() << QString::fromLatin1(result); + } + return str; +} diff --git a/KelvinDashboardService/DapLogReader.h b/KelvinDashboardService/DapLogReader.h new file mode 100644 index 000000000..6362047b8 --- /dev/null +++ b/KelvinDashboardService/DapLogReader.h @@ -0,0 +1,23 @@ +#ifndef DAPLOGREADER_H +#define DAPLOGREADER_H + +#include <QObject> +#include <QString> +#include <QProcess> +#include <QDebug> + +class DapLogReader : public QObject +{ + Q_OBJECT + +public: + explicit DapLogReader(QObject *parent = nullptr); + +signals: + +public slots: + + QList<QString> request(int aiTimeStamp, int aiRowCount); +}; + +#endif // DAPLOGREADER_H diff --git a/KelvinDashboardService/KelvinDashboardService.pro b/KelvinDashboardService/KelvinDashboardService.pro index 2fecb7026..6f8faa372 100755 --- a/KelvinDashboardService/KelvinDashboardService.pro +++ b/KelvinDashboardService/KelvinDashboardService.pro @@ -40,12 +40,14 @@ SOURCES += \ main.cpp \ DapChainDashboardService.cpp \ DapChainNode.cpp \ - DapChainNodeCache.cpp + DapChainNodeCache.cpp \ + DapLogReader.cpp HEADERS += \ DapChainDashboardService.h \ DapChainNode.h \ - DapChainNodeCache.h + DapChainNodeCache.h \ + DapLogReader.h include (../libdap-qt/libdap-qt.pri) include (../libKelvinDashboardCommon/libKelvinDashboardCommon.pri) diff --git a/KelvinDashboardService/main.cpp b/KelvinDashboardService/main.cpp index 4bbb8de1c..f83eef8b7 100755 --- a/KelvinDashboardService/main.cpp +++ b/KelvinDashboardService/main.cpp @@ -5,6 +5,7 @@ #include "DapHalper.h" #include "DapChainDashboardService.h" #include "DapLogger.h" +#include "DapLogReader.h" int main(int argc, char *argv[]) { @@ -26,7 +27,7 @@ int main(int argc, char *argv[]) a.setOrganizationName("DEMLABS"); a.setOrganizationDomain("demlabs.com"); a.setApplicationName("KelvinDashboardService"); - + DapLogger dapLogger; /// TODO: The code is commented out at the time of developing the logging strategy in the project //#ifndef QT_DEBUG @@ -34,7 +35,10 @@ int main(int argc, char *argv[]) dapLogger.setLogFile(QString("/opt/%1/log/%2Service.log").arg(QString(DAP_BRAND)).arg(DAP_BRAND)); #endif //#endif - + DapLogReader dapLogReader; + auto var = dapLogReader.request(0, 100); + auto var1 = dapLogReader.request(1, 100); + auto var2 = dapLogReader.request(2, 100); // Creating the main application object DapChainDashboardService service; service.start(); -- GitLab