mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2025-12-13 06:56:56 +03:00
Enhance UI (#1243)
* Temporarily disable data file writing as it can cause crashs, see https://github.com/jomjol/AI-on-the-edge-device/issues/1225 * removed edit function in graph as we don't need that in a release * . * improve log viewer * replaced logfile enable/disable with enum to select log level. At least errors always will be logged (as before) * . * . * colorize log * scroll down * improve log reload
This commit is contained in:
@@ -460,13 +460,22 @@ bool ClassFlowControll::ReadParameter(FILE* pfile, string& aktparamgraph)
|
||||
}
|
||||
if ((toUpper(zerlegt[0]) == "LOGFILE") && (zerlegt.size() > 1))
|
||||
{
|
||||
if (toUpper(zerlegt[1]) == "TRUE")
|
||||
/* matches esp_log_level_t */
|
||||
if ((toUpper(zerlegt[1]) == "TRUE") || (toUpper(zerlegt[1]) == "2"))
|
||||
{
|
||||
LogFile.SwitchOnOff(true);
|
||||
LogFile.setLogLevel(ESP_LOG_WARN);
|
||||
}
|
||||
if (toUpper(zerlegt[1]) == "FALSE")
|
||||
else if ((toUpper(zerlegt[1]) == "FALSE") || (toUpper(zerlegt[1]) == "0") || (toUpper(zerlegt[1]) == "1"))
|
||||
{
|
||||
LogFile.SwitchOnOff(false);
|
||||
LogFile.setLogLevel(ESP_LOG_ERROR);
|
||||
}
|
||||
else if (toUpper(zerlegt[1]) == "3")
|
||||
{
|
||||
LogFile.setLogLevel(ESP_LOG_INFO);
|
||||
}
|
||||
else if (toUpper(zerlegt[1]) == "4")
|
||||
{
|
||||
LogFile.setLogLevel(ESP_LOG_DEBUG);
|
||||
}
|
||||
}
|
||||
if ((toUpper(zerlegt[0]) == "LOGFILERETENTIONINDAYS") && (zerlegt.size() > 1))
|
||||
@@ -505,12 +514,7 @@ bool ClassFlowControll::ReadParameter(FILE* pfile, string& aktparamgraph)
|
||||
{
|
||||
SetupModeActive = true;
|
||||
}
|
||||
}
|
||||
|
||||
if ((toUpper(zerlegt[0]) == "LOGLEVEL") && (zerlegt.size() > 1)) // TODO there seems to be no such parameter in the config, but there is one called "Debug_Logfile_value1"!
|
||||
{
|
||||
LogFile.setLogLevel((esp_log_level_t)(stoi(zerlegt[1]))); // Gets mapped to esp_log_level_t
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
AutoIntervalShared = AutoIntervall;
|
||||
|
||||
@@ -80,9 +80,10 @@ void ClassLogFile::WriteToData(std::string _timestamp, std::string _name, std::s
|
||||
FILE* pFile;
|
||||
std::string zwtime;
|
||||
|
||||
if (!doLogFile){
|
||||
// TODO add separate parameter to disable write of data.
|
||||
/*if (!doLogFile){
|
||||
return;
|
||||
}
|
||||
}*/
|
||||
|
||||
ESP_LOGD(TAG, "Datalogfile: %s", logpath.c_str());
|
||||
pFile = fopen(logpath.c_str(), "a+");
|
||||
@@ -121,7 +122,7 @@ void ClassLogFile::WriteToDedicatedFile(std::string _fn, esp_log_level_t level,
|
||||
std::string zwtime;
|
||||
std::string logline = "";
|
||||
|
||||
if (!doLogFile && level != ESP_LOG_ERROR){ // Only write to file if logfile is enabled or its an error message
|
||||
if (level > loglevel) {// Only write to file if loglevel is below threshold
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -147,9 +148,6 @@ void ClassLogFile::WriteToDedicatedFile(std::string _fn, esp_log_level_t level,
|
||||
|
||||
std::string loglevelString;
|
||||
switch(level) {
|
||||
case ESP_LOG_NONE:
|
||||
loglevelString = "NONE";
|
||||
break;
|
||||
case ESP_LOG_ERROR:
|
||||
loglevelString = "ERR";
|
||||
break;
|
||||
@@ -165,6 +163,7 @@ void ClassLogFile::WriteToDedicatedFile(std::string _fn, esp_log_level_t level,
|
||||
case ESP_LOG_VERBOSE:
|
||||
loglevelString = "VER";
|
||||
break;
|
||||
case ESP_LOG_NONE:
|
||||
default:
|
||||
loglevelString = "NONE";
|
||||
break;
|
||||
@@ -178,8 +177,37 @@ void ClassLogFile::WriteToDedicatedFile(std::string _fn, esp_log_level_t level,
|
||||
}
|
||||
}
|
||||
|
||||
void ClassLogFile::SwitchOnOff(bool _doLogFile){
|
||||
doLogFile = _doLogFile;
|
||||
void ClassLogFile::setLogLevel(esp_log_level_t _logLevel){
|
||||
loglevel = _logLevel;
|
||||
|
||||
std::string levelText;
|
||||
|
||||
switch(_logLevel) {
|
||||
case ESP_LOG_WARN:
|
||||
levelText = "WARNING";
|
||||
break;
|
||||
|
||||
case ESP_LOG_INFO:
|
||||
levelText = "INFO";
|
||||
break;
|
||||
|
||||
case ESP_LOG_DEBUG:
|
||||
levelText = "DEBUG";
|
||||
break;
|
||||
case ESP_LOG_ERROR:
|
||||
default:
|
||||
levelText = "ERROR";
|
||||
break;
|
||||
}
|
||||
|
||||
ESP_LOGI(TAG, "Logfile Log Level set to %s", levelText.c_str());
|
||||
|
||||
/*
|
||||
LogFile.WriteToFile(ESP_LOG_ERROR, "Test");
|
||||
LogFile.WriteToFile(ESP_LOG_WARN, "Test");
|
||||
LogFile.WriteToFile(ESP_LOG_INFO, "Test");
|
||||
LogFile.WriteToFile(ESP_LOG_DEBUG, "Test");
|
||||
*/
|
||||
};
|
||||
|
||||
void ClassLogFile::SetRetention(unsigned short _retentionInDays){
|
||||
@@ -325,7 +353,6 @@ ClassLogFile::ClassLogFile(std::string _logroot, std::string _logfile, std::stri
|
||||
logfile = _logfile;
|
||||
datafile = _datafile;
|
||||
dataroot = _logdatapath;
|
||||
doLogFile = true;
|
||||
retentionInDays = 10;
|
||||
loglevel = ESP_LOG_INFO;
|
||||
MakeDir("/sdcard/log/data");
|
||||
|
||||
@@ -10,7 +10,6 @@ private:
|
||||
std::string logfile;
|
||||
std::string dataroot;
|
||||
std::string datafile;
|
||||
bool doLogFile;
|
||||
unsigned short retentionInDays;
|
||||
esp_log_level_t loglevel;
|
||||
public:
|
||||
@@ -18,11 +17,9 @@ public:
|
||||
|
||||
std::string getESPHeapInfo();
|
||||
|
||||
void setLogLevel(esp_log_level_t i){loglevel = i;};
|
||||
|
||||
void WriteHeapInfo(std::string _id);
|
||||
|
||||
void SwitchOnOff(bool _doLogFile);
|
||||
void setLogLevel(esp_log_level_t _logLevel);
|
||||
void SetRetention(unsigned short _retentionInDays);
|
||||
|
||||
void WriteToFile(esp_log_level_t level, std::string info, bool _time = true);
|
||||
|
||||
Reference in New Issue
Block a user