стабильное логгирование

This commit is contained in:
Dmitry Borisenko
2022-08-26 00:01:01 +02:00
parent 4bce800e1d
commit f65e16f674
9 changed files with 31 additions and 29 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,17 +1,16 @@
<!DOCTYPE html> <!DOCTYPE html>
<html lang="en"> <html lang="en">
<head> <head>
<meta charset='utf-8'> <meta charset="utf-8" />
<meta name='viewport' content='width=device-width,initial-scale=1'> <meta name="viewport" content="width=device-width,initial-scale=1" />
<title>IoT Manager 4.1.8</title> <title>IoT Manager 4.1.9</title>
<link rel='icon' type='image/png' href='/favicon.ico'> <link rel="icon" type="image/png" href="/favicon.ico" />
<link rel='stylesheet' href='/build/bundle.css'> <link rel="stylesheet" href="/build/bundle.css" />
<script defer src='/build/bundle.js'></script> <script defer src="/build/bundle.js"></script>
</head> </head>
<body> <body></body>
</body>
</html> </html>

View File

@@ -32,7 +32,7 @@
#endif #endif
#ifdef esp32_4mb #ifdef esp32_4mb
#define USE_LITTLEFS false #define USE_LITTLEFS true
#endif #endif
#define START_DATETIME 1640995200 // 01.01.2022 00:00:00 константа для сокращения unix time #define START_DATETIME 1640995200 // 01.01.2022 00:00:00 константа для сокращения unix time

View File

@@ -12,4 +12,5 @@ extern const String filepath(const String& filename);
extern bool cutFile(const String& src, const String& dst); extern bool cutFile(const String& src, const String& dst);
extern size_t countLines(const String filename); extern size_t countLines(const String filename);
void removeFile(const String& filename); void removeFile(const String& filename);
void cleanDirectory(String path);
extern void onFlashWrite(); extern void onFlashWrite();

View File

@@ -134,5 +134,6 @@ build_src_filter =
+<modules\exec\Mcp23017> +<modules\exec\Mcp23017>
+<modules\exec\Mp3> +<modules\exec\Mp3>
+<modules\exec\Pwm32> +<modules\exec\Pwm32>
+<modules\exec\SysExt>
+<modules\display\Lcd2004> +<modules\display\Lcd2004>

View File

@@ -133,9 +133,9 @@ void webSocketEvent(uint8_t num, WStype_t type, uint8_t* payload, size_t length)
if (headerStr == "/reboot|") { if (headerStr == "/reboot|") {
ESP.restart(); ESP.restart();
} }
//команда обновления esp// //команда очистки всех логов esp//
if (headerStr == "/update|") { if (headerStr == "/clean|") {
upgrade_firmware(3); cleanDirectory("logs");
} }
//Прием сообщений cotrol ============================================================================== //Прием сообщений cotrol ==============================================================================

View File

@@ -3,7 +3,7 @@
#include "NTP.h" #include "NTP.h"
//раскомментировать если нужна цельная выгрузка графиков //раскомментировать если нужна цельная выгрузка графиков
//#define SOLID_UPLOADING #define SOLID_UPLOADING
class Loging : public IoTItem { class Loging : public IoTItem {
private: private:
@@ -177,16 +177,6 @@ class Loging : public IoTItem {
publishChart(id, oneSingleJson); publishChart(id, oneSingleJson);
} }
void cleanLog() {
String directory = "logs/" + id;
auto dir = FileFS.openDir(directory);
while (dir.next()) {
String fname = dir.fileName();
removeFile(directory + "/" + fname);
SerialPrint("I", "Loging " + id, fname + " deleted");
}
}
int calculateMaxCount() { int calculateMaxCount() {
return 86400 / interval; return 86400 / interval;
} }

View File

@@ -190,6 +190,17 @@ void removeFile(const String& filename) {
} }
} }
//очищаем директорию с файлами
void cleanDirectory(String path) {
auto dir = FileFS.openDir(path);
while (dir.next()) {
String fname = dir.fileName();
removeFile(path + "/" + fname);
SerialPrint("I", "Files", fname + " deleted");
}
onFlashWrite();
}
//счетчик количества записей на флешь за сеанс //счетчик количества записей на флешь за сеанс
void onFlashWrite() { void onFlashWrite() {
flashWriteNumber++; flashWriteNumber++;