Weblog json dynamic

This commit is contained in:
MichaelDvP
2023-10-10 09:48:11 +02:00
parent 020bb628d6
commit ae1b6fc67b

View File

@@ -174,15 +174,19 @@ char * WebLogService::messagetime(char * out, const uint64_t t, const size_t buf
strlcpy(out, uuid::log::format_timestamp_ms(t, 3).c_str(), bufsize);
} else {
time_t t1 = time_offset_ + t / 1000ULL;
strftime(out, bufsize, "%F %T", localtime(&t1));
snprintf(out, bufsize, "%s.%03d", out, (uint16_t)(t % 1000));
char timestr[bufsize];
strftime(timestr, bufsize, "%F %T", localtime(&t1));
snprintf(out, bufsize, "%s.%03d", timestr, (uint16_t)(t % 1000));
}
return out;
}
// send to web eventsource
void WebLogService::transmit(const QueuedLogMessage & message) {
StaticJsonDocument<EMSESP_JSON_SIZE_MEDIUM> jsonDocument;
DynamicJsonDocument jsonDocument(EMSESP_JSON_SIZE_LARGE);
if (jsonDocument.capacity() == 0) {
return;
}
JsonObject logEvent = jsonDocument.to<JsonObject>();
char time_string[25];