diff --git a/CHANGELOG.md b/CHANGELOG.md index 4f1887cb2..a17df4982 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,6 +19,7 @@ All notable changes to this project will be documented in this file. - Matter Contact sensor was not triggering any update (#20232) - CVE-2021-36603 Cross Site Scripting (XSS) vulnerability (#12221) - ESP32 piezo ceramic buzzer doesn't buzz (#20118) +- Syslog server warning caused by lack of field and hostname starting with 'z' (#14689) ### Removed diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 8953e8264..52c7e1e08 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -130,6 +130,7 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm ### Fixed - CVE-2021-36603 Cross Site Scripting (XSS) vulnerability [#12221](https://github.com/arendst/Tasmota/issues/12221) +- Syslog server warning caused by lack of field and hostname starting with 'z' [#14689](https://github.com/arendst/Tasmota/issues/14689) - ESP32 piezo ceramic buzzer doesn't buzz [#20118](https://github.com/arendst/Tasmota/issues/20118) - Matter Contact sensor was not triggering any update [#20232](https://github.com/arendst/Tasmota/issues/20232) diff --git a/tasmota/tasmota_support/support.ino b/tasmota/tasmota_support/support.ino index 361e4c425..c2e8ba855 100755 --- a/tasmota/tasmota_support/support.ino +++ b/tasmota/tasmota_support/support.ino @@ -2297,8 +2297,9 @@ void SyslogAsync(bool refresh) { char* line; size_t len; while (GetLog(TasmotaGlobal.syslog_level, &index, &line, &len)) { - // 00:00:02.096 HTP: Web server active on wemos5 with IP address 192.168.2.172 - // HTP: Web server active on wemos5 with IP address 192.168.2.172 + // <--- mxtime ---> TAG MSG + // 00:00:02.096-029 HTP: Web server active on wemos5 with IP address 192.168.2.172 + // HTP: Web server active on wemos5 with IP address 192.168.2.172 uint32_t mxtime = strchr(line, ' ') - line +1; // Remove mxtime if (mxtime > 0) { uint32_t current_hash = GetHash(SettingsText(SET_SYSLOG_HOST), strlen(SettingsText(SET_SYSLOG_HOST))); @@ -2321,7 +2322,14 @@ void SyslogAsync(bool refresh) { } char header[64]; - snprintf_P(header, sizeof(header), PSTR("%s ESP-"), NetworkHostname()); + // RFC3164 - BSD syslog protocol - TIMESTAMP HOSTNAME TAG MSG + // = Facility 16 (= local use 0), Severity 6 (= informational) => 16 * 8 + 6 = <134> + // TIMESTAMP = Mmm dd hh:mm:ss + // <134>Jan 1 00:00:02 wemos5 ESP-HTP: server active on wemos5 with IP address 192.168.2.172 + snprintf_P(header, sizeof(header), PSTR("<134>%s %s ESP-"), GetSyslogDate(line).c_str(), NetworkHostname()); + // Legacy format +// snprintf_P(header, sizeof(header), PSTR("%s ESP-"), NetworkHostname()); + char* line_start = line +mxtime; #ifdef ESP8266 // Packets over 1460 bytes are not send diff --git a/tasmota/tasmota_support/support_rtc.ino b/tasmota/tasmota_support/support_rtc.ino index ff93c14d6..95c1af38a 100644 --- a/tasmota/tasmota_support/support_rtc.ino +++ b/tasmota/tasmota_support/support_rtc.ino @@ -109,6 +109,18 @@ String GetBuildDateAndTime(void) { return String(bdt); // 2017-03-07T11:08:02 } +String GetSyslogDate(char* mxtime) { + // Mmm dd hh:mm:ss + // Jan 3 09:23:45 + // Assuming the day hasn't changed yet ;-) + uint32_t month_idx = (RtcTime.month -1) * 3; + char month[4] = { 0 }; + strncpy_P(month, kMonthNamesEnglish + month_idx, 3); + char dt[16]; + snprintf_P(dt, sizeof(dt), PSTR("%s %2d %s"), month, RtcTime.day_of_month, mxtime); + return String(dt); +} + String GetMinuteTime(uint32_t minutes) { char tm[6]; snprintf_P(tm, sizeof(tm), PSTR("%02d:%02d"), minutes / 60, minutes % 60);