write logfile logs earlier, shorten startup banner, add uptime to logfile (#1443)

Co-authored-by: CaCO3 <caco@ruinelli.ch>
This commit is contained in:
CaCO3
2022-12-02 16:59:25 +01:00
committed by GitHub
parent 7e997889aa
commit 45a3138d28
4 changed files with 23 additions and 25 deletions

View File

@@ -164,7 +164,9 @@ void ClassLogFile::WriteToDedicatedFile(std::string _fn, esp_log_level_t level,
break; break;
} }
logline = logline + "\t<" + loglevelString + ">\t" + message.c_str() + "\n"; char uptime[20];
snprintf(uptime, sizeof(uptime), "%8d", (uint32_t)(esp_timer_get_time()/1000/1000)); // in seconds
logline = "[" + std::string(uptime) + "] " + logline + "\t<" + loglevelString + ">\t" + message + "\n";
fputs(logline.c_str(), pFile); fputs(logline.c_str(), pFile);
fclose(pFile); fclose(pFile);
} else { } else {

View File

@@ -170,26 +170,16 @@ extern "C" void app_main(void)
string versionFormated = "Tag: '" + std::string(GIT_TAG) + "', " + versionFormated; string versionFormated = "Tag: '" + std::string(GIT_TAG) + "', " + versionFormated;
} }
ESP_LOGD(TAG, "============================================================================================="); LogFile.CreateLogDirectories();
ESP_LOGD(TAG, "%s", versionFormated.c_str());
ESP_LOGD(TAG, "=============================================================================================");
ESP_LOGD(TAG, "Reset reason: %s", getResetReason().c_str());
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "=================================================");
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "==================== Startup ====================");
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "=================================================");
LogFile.WriteToFile(ESP_LOG_INFO, TAG, versionFormated);
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Reset reason: " + getResetReason());
CheckOTAUpdate(); CheckOTAUpdate();
LogFile.CreateLogDirectories();
CheckUpdate(); CheckUpdate();
/*
int mk_ret = mkdir("/sdcard/new_fd_mkdir", 0775);
ESP_LOGI(TAG, "mkdir ret %d", mk_ret);
mk_ret = mkdir("/sdcard/new_fd_mkdir/test", 0775);
ESP_LOGI(TAG, "mkdir ret %d", mk_ret);
MakeDir("/sdcard/test2");
MakeDir("/sdcard/test2/intern");
*/
char *ssid = NULL, *passwd = NULL, *hostname = NULL, *ip = NULL, *gateway = NULL, *netmask = NULL, *dns = NULL; char *ssid = NULL, *passwd = NULL, *hostname = NULL, *ip = NULL, *gateway = NULL, *netmask = NULL, *dns = NULL;
LoadWlanFromFile("/sdcard/wlan.ini", ssid, passwd, hostname, ip, gateway, netmask, dns); LoadWlanFromFile("/sdcard/wlan.ini", ssid, passwd, hostname, ip, gateway, netmask, dns);
@@ -229,11 +219,9 @@ extern "C" void app_main(void)
setBootTime(); setBootTime();
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "============================================================================================="); LogFile.WriteToFile(ESP_LOG_INFO, TAG, "=================================================");
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "=================================== Main Started ============================================"); LogFile.WriteToFile(ESP_LOG_INFO, TAG, "================== Main Started =================");
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "============================================================================================="); LogFile.WriteToFile(ESP_LOG_INFO, TAG, "=================================================");
LogFile.WriteToFile(ESP_LOG_INFO, TAG, versionFormated);
LogFile.WriteToFile(ESP_LOG_INFO, TAG, "Reset reason: " + getResetReason());
if (getHTMLcommit() != std::string(GIT_REV)) { if (getHTMLcommit() != std::string(GIT_REV)) {
LogFile.WriteToFile(ESP_LOG_WARN, TAG, std::string("Web UI version (") + getHTMLcommit() + ") does not match firmware version (" + std::string(GIT_REV) + ") !"); LogFile.WriteToFile(ESP_LOG_WARN, TAG, std::string("Web UI version (") + getHTMLcommit() + ") does not match firmware version (" + std::string(GIT_REV) + ") !");

View File

@@ -1268,7 +1268,7 @@ textarea {
<input type="number" id="AutoTimer_Intervall_value1" size="13" min="3" step="any"> <input type="number" id="AutoTimer_Intervall_value1" size="13" min="3" step="any">
</td> </td>
<td style="font-size: 80%;"> <td style="font-size: 80%;">
Interval in which the number(s) are read (in minutes). If a run takes longer than this interval, the next run gets postponed until the current run completes. Interval in which the number(s) are read (in minutes). If a digitalization round takes longer than this interval, the next run gets postponed until the current run completes.
</td> </td>
</tr> </tr>

View File

@@ -57,6 +57,10 @@
function processLogLine(line, index, arr) { function processLogLine(line, index, arr) {
/* Make sure the whitespaces in the uptime field get persevered */
uptimePart = line.slice(0, line.indexOf("]")).replace(/ /g, "&nbsp;");
line = uptimePart + line.slice(line.indexOf("]"))
if (line.includes("&lt;WRN&gt;")) { if (line.includes("&lt;WRN&gt;")) {
arr[index] = "<span style=\"color:#e83c00\">" + line + "</span>"; arr[index] = "<span style=\"color:#e83c00\">" + line + "</span>";
} }
@@ -66,7 +70,10 @@
else if (line.includes("&lt;DBG&gt;")) { else if (line.includes("&lt;DBG&gt;")) {
arr[index] = "<span style=\"color:gray\">" + line + "</span>"; arr[index] = "<span style=\"color:gray\">" + line + "</span>";
} }
else {
arr[index] = line;
}
arr[index] += "<br>"; arr[index] += "<br>";
} }
@@ -80,7 +87,8 @@
return res.text(); return res.text();
}) })
.then((log) => { .then((log) => {
log = log.replace(/</g, "&lt;").replace(/>/g, "&gt;"); log = log.replace(/</g, "&lt;");
log = log.replace(/>/g, "&gt;");
logArr = log.split("\n"); logArr = log.split("\n");
logArr.forEach(processLogLine); logArr.forEach(processLogLine);