This commit is contained in:
proddy
2020-06-06 21:42:17 +02:00
parent c6ede0959b
commit ddf5872b8b

View File

@@ -387,18 +387,24 @@ bool SyslogService::can_transmit() {
} }
bool SyslogService::transmit(const QueuedLogMessage & message) { bool SyslogService::transmit(const QueuedLogMessage & message) {
/*
// modifications by Proddy. From https://github.com/proddy/EMS-ESP/issues/395#issuecomment-640053528
struct tm tm; struct tm tm;
tm.tm_year = 0; tm.tm_year = 0;
if (message.time_.tv_sec != (time_t)-1) { if (message.time_.tv_sec != (time_t)-1) {
gmtime_r(&message.time_.tv_sec, &tm); gmtime_r(&message.time_.tv_sec, &tm);
} }
*/
if (udp_.beginPacket(host_, port_) != 1) { if (udp_.beginPacket(host_, port_) != 1) {
last_transmit_ = uuid::get_uptime_ms(); last_transmit_ = uuid::get_uptime_ms();
return false; return false;
} }
udp_.printf_P(PSTR("<%u>1 "), ((unsigned int)message.content_->facility * 8) + std::min(7U, (unsigned int)message.content_->level)); udp_.printf_P(PSTR("<%u>1 "), ((unsigned int)message.content_->facility * 8) + std::min(7U, (unsigned int)message.content_->level));
/*
if (tm.tm_year != 0) { if (tm.tm_year != 0) {
udp_.printf_P(PSTR("%04u-%02u-%02uT%02u:%02u:%02u.%06luZ"), udp_.printf_P(PSTR("%04u-%02u-%02uT%02u:%02u:%02u.%06luZ"),
tm.tm_year + 1900, tm.tm_year + 1900,
@@ -411,6 +417,9 @@ bool SyslogService::transmit(const QueuedLogMessage & message) {
} else { } else {
udp_.print('-'); udp_.print('-');
} }
*/
udp_.print('-');
udp_.printf_P(PSTR(" %s - - - - \xEF\xBB\xBF"), hostname_.c_str()); udp_.printf_P(PSTR(" %s - - - - \xEF\xBB\xBF"), hostname_.c_str());
udp_.print(uuid::log::format_timestamp_ms(message.content_->uptime_ms, 3).c_str()); udp_.print(uuid::log::format_timestamp_ms(message.content_->uptime_ms, 3).c_str());