From 162c92bc3b3a7dbe3d1484f7efc812aa36b23bcb Mon Sep 17 00:00:00 2001 From: Arseniy-Movshev Date: Sun, 2 Jul 2023 12:11:28 +0100 Subject: Move fileaddrecord to common.h so that it can be used from qml plugin --- daemon/logger.cpp | 12 ------------ daemon/logger.h | 1 - daemon/sensorPlugins/heartrateSensor.cpp | 1 + daemon/sensorPlugins/stepCounter.cpp | 1 + 4 files changed, 2 insertions(+), 13 deletions(-) (limited to 'daemon') diff --git a/daemon/logger.cpp b/daemon/logger.cpp index e8f75ba..7e06c63 100644 --- a/daemon/logger.cpp +++ b/daemon/logger.cpp @@ -111,18 +111,6 @@ bool Logger::getDaemonFresh() { } } -void fileAddRecord(QString sensorPrefix, QString logdata, QDateTime recordTime) { //adds a record to today's log file for the given sensor - qDebug() << fileNameForDate(recordTime.date(), sensorPrefix); - QFile file(fileNameForDate(recordTime.date(), sensorPrefix)); - if (!file.open(QIODevice::ReadWrite | QIODevice::Text)) { - qDebug() << "failed to open file"; - return; - } - file.seek(file.size()); - QTextStream out(&file); - out << QString::number(recordTime.currentSecsSinceEpoch()) + ":" + logdata + "\n"; - file.close(); -} bool dayFileExists(QString sensorPrefix, QDateTime dateTime) { return QFile::exists(fileNameForDate(dateTime.date(), sensorPrefix)); } diff --git a/daemon/logger.h b/daemon/logger.h index 328c0d7..c16908d 100644 --- a/daemon/logger.h +++ b/daemon/logger.h @@ -47,7 +47,6 @@ private: bool getDaemonFresh(); }; - void fileAddRecord(QString sensorPrefix, QString logdata, QDateTime recordTime = QDateTime::currentDateTime()); //adds a record to today's log file for the given sensor bool dayFileExists(QString sensorPrefix, QDateTime date = QDateTime::currentDateTime()); //check if today has a log file for the given sensor QStringList fileGetPrevRecord(QString sensorPrefix, QDateTime recordTime = QDateTime::currentDateTime()); //works backwards to find the last record in today's file before the given time - returns nothing if no file is found. void setupFilePath(QString sensorPrefix); //sets up the paths for sensors to write into diff --git a/daemon/sensorPlugins/heartrateSensor.cpp b/daemon/sensorPlugins/heartrateSensor.cpp index 8b329b9..d03703c 100644 --- a/daemon/sensorPlugins/heartrateSensor.cpp +++ b/daemon/sensorPlugins/heartrateSensor.cpp @@ -16,6 +16,7 @@ #include #include "../logger.h" +#include "../../common.h" #include "heartrateSensor.h" diff --git a/daemon/sensorPlugins/stepCounter.cpp b/daemon/sensorPlugins/stepCounter.cpp index fd09e81..87c1c3c 100644 --- a/daemon/sensorPlugins/stepCounter.cpp +++ b/daemon/sensorPlugins/stepCounter.cpp @@ -19,6 +19,7 @@ #include #include "../logger.h" +#include "../../common.h" #include "stepCounter.h" -- cgit v1.2.3-54-g00ecf