diff --git a/code/components/jomjol_flowcontroll/ClassFlowControll.cpp b/code/components/jomjol_flowcontroll/ClassFlowControll.cpp index 5b07ab74..ab244c56 100644 --- a/code/components/jomjol_flowcontroll/ClassFlowControll.cpp +++ b/code/components/jomjol_flowcontroll/ClassFlowControll.cpp @@ -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; diff --git a/code/components/jomjol_logfile/ClassLogFile.cpp b/code/components/jomjol_logfile/ClassLogFile.cpp index d866eb53..84674130 100644 --- a/code/components/jomjol_logfile/ClassLogFile.cpp +++ b/code/components/jomjol_logfile/ClassLogFile.cpp @@ -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"); diff --git a/code/components/jomjol_logfile/ClassLogFile.h b/code/components/jomjol_logfile/ClassLogFile.h index 79c3fd41..b397d462 100644 --- a/code/components/jomjol_logfile/ClassLogFile.h +++ b/code/components/jomjol_logfile/ClassLogFile.h @@ -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); diff --git a/sd-card/html/edit_config_param.html b/sd-card/html/edit_config_param.html index b58d23dd..26f2a5ab 100644 --- a/sd-card/html/edit_config_param.html +++ b/sd-card/html/edit_config_param.html @@ -745,7 +745,7 @@ textarea {

+ - Enabling GPIO handler, disable by default integrated flash light.
Please enable it with GPIO4 (internal flash LED) settings or GPIO12 (external LED).

@@ -1249,18 +1249,20 @@ textarea { - + - Turn on/off the extended logging + Set the level of the logging to the SD-Card.
Warning: DEBUG or INFO might damage the SD-Card if enabled longterm due to excessive writes to the SD-Card! - + @@ -1431,7 +1433,7 @@ function WriteParameter(_param, _category, _cat, _name, _optional, _number = -1) } if (!_isFound) { - _zw_txt = "In the selectd field the value '" + textToFind + "' in the parameter '"; + _zw_txt = "In the selected field the value '" + textToFind + "' in the parameter '"; _zw_txt = _zw_txt + _cat + "' in the field '" + _name + "' is invalid.\nPLEASE CHECK BEFORE SAVING!"; alert(_zw_txt); } @@ -1472,7 +1474,7 @@ function WriteParameter(_param, _category, _cat, _name, _optional, _number = -1) } if (!_isFound) { - _zw_txt = "In the selectd field the value '" + textToFind + "' in the section '"; + _zw_txt = "In the selected field the value '" + textToFind + "' in the section '"; _zw_txt = _zw_txt + _cat + "' in the field '" + _name + "' is invalid.\nPLEASE CHECK BEFORE SAVING!"; alert(_zw_txt); } diff --git a/sd-card/html/graph.html b/sd-card/html/graph.html index cb2fa483..b89a37c5 100644 --- a/sd-card/html/graph.html +++ b/sd-card/html/graph.html @@ -1,4 +1,3 @@ - @@ -18,22 +17,21 @@ var el = document.getElementById('cnsl'); el && eval(el.value); } - - +
- - - + + + - + - - \ No newline at end of file + diff --git a/sd-card/html/index.html b/sd-card/html/index.html index c98d88c8..6dc2df39 100644 --- a/sd-card/html/index.html +++ b/sd-card/html/index.html @@ -68,7 +68,7 @@ diff --git a/sd-card/html/log.html b/sd-card/html/log.html new file mode 100644 index 00000000..cfd7d742 --- /dev/null +++ b/sd-card/html/log.html @@ -0,0 +1,100 @@ + + + + + +
+
+ + + +
+



Loading Logfile, please wait...
+ +
+ + + +