mirror of
https://github.com/emsesp/EMS-ESP32.git
synced 2025-12-07 00:09:51 +03:00
Weblog json dynamic
This commit is contained in:
@@ -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);
|
strlcpy(out, uuid::log::format_timestamp_ms(t, 3).c_str(), bufsize);
|
||||||
} else {
|
} else {
|
||||||
time_t t1 = time_offset_ + t / 1000ULL;
|
time_t t1 = time_offset_ + t / 1000ULL;
|
||||||
strftime(out, bufsize, "%F %T", localtime(&t1));
|
char timestr[bufsize];
|
||||||
snprintf(out, bufsize, "%s.%03d", out, (uint16_t)(t % 1000));
|
strftime(timestr, bufsize, "%F %T", localtime(&t1));
|
||||||
|
snprintf(out, bufsize, "%s.%03d", timestr, (uint16_t)(t % 1000));
|
||||||
}
|
}
|
||||||
return out;
|
return out;
|
||||||
}
|
}
|
||||||
|
|
||||||
// send to web eventsource
|
// send to web eventsource
|
||||||
void WebLogService::transmit(const QueuedLogMessage & message) {
|
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>();
|
JsonObject logEvent = jsonDocument.to<JsonObject>();
|
||||||
char time_string[25];
|
char time_string[25];
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user