From bba5ba008ebc3ab6f751553709edb07d3c1f3704 Mon Sep 17 00:00:00 2001 From: Theo Arends <11044339+arendst@users.noreply.github.com> Date: Mon, 9 Jun 2025 17:42:58 +0200 Subject: [PATCH] Format syslog messages according to RFC5424 adding local log time (#23509) --- CHANGELOG.md | 3 ++- RELEASENOTES.md | 2 ++ tasmota/tasmota_support/support.ino | 37 +++++++++++++---------------- 3 files changed, 21 insertions(+), 21 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 4e77ce38d..a3b5f0639 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -26,7 +26,8 @@ All notable changes to this project will be documented in this file. - Berry change number parser for json to reuse same parser as lexer (#23505) - Berry increase web hooks from 16 to 32 (#23507) - ESP32 LVGL library from v9.2.2 to v9.3.0 (#23518) -- Zigbee improved message when coordinator failed to start +- Zigbee improved message when coordinator failed to start (#23525) +- Format syslog messages according to RFC5424 adding local log time (#23509) ### Fixed - Haspmota `haspmota.parse()` page parsing (#23403) diff --git a/RELEASENOTES.md b/RELEASENOTES.md index 65c411404..868c58627 100644 --- a/RELEASENOTES.md +++ b/RELEASENOTES.md @@ -144,6 +144,8 @@ The latter links can be used for OTA upgrades too like ``OtaUrl https://ota.tasm - GPIOViewer from v1.6.2 to v1.6.3 (No functional change) - Allow command `WebRefresh` minimum from 1000 to 400 mSec - Increase number of supported LoRaWan nodes from 4 to 16 +- Format syslog messages according to RFC5424 adding local log time [#23509](https://github.com/arendst/Tasmota/issues/23509) +- Zigbee improved message when coordinator failed to start [#23525](https://github.com/arendst/Tasmota/issues/23525) - Berry change number parser for json to reuse same parser as lexer [#23505](https://github.com/arendst/Tasmota/issues/23505) - Berry increase web hooks from 16 to 32 [#23507](https://github.com/arendst/Tasmota/issues/23507) diff --git a/tasmota/tasmota_support/support.ino b/tasmota/tasmota_support/support.ino index f5a72ad7f..ba0117893 100755 --- a/tasmota/tasmota_support/support.ino +++ b/tasmota/tasmota_support/support.ino @@ -2462,7 +2462,7 @@ void SyslogAsync(bool refresh) { return; } - char header[64]; + char header[100]; /* Legacy format (until v13.3.0.1) - HOSTNAME TAG: MSG SYSLOG-MSG = wemos5 ESP-HTP: Web server active on wemos5 with IP address 192.168.2.172 Result = 2023-12-20T13:41:11.825749+01:00 wemos5 ESP-HTP: Web server active on wemos5 with IP address 192.168.2.172 @@ -2484,11 +2484,7 @@ void SyslogAsync(bool refresh) { LOG_LEVEL_DEBUG 3 -> severity level 7 - Debug LOG_LEVEL_DEBUG_MORE 4 -> severity level 7 - Debug */ - snprintf_P(header, sizeof(header), PSTR("<%d>%s ESP-"), 128 + min(loglevel * 3, 7), NetworkHostname()); - -// SYSLOG-MSG = <134>wemos5 Tasmota HTP: Web server active on wemos5 with IP address 192.168.2.172 -// Result = 2023-12-21T11:31:50.378816+01:00 wemos5 Tasmota HTP: Web server active on wemos5 with IP address 192.168.2.172 -// snprintf_P(header, sizeof(header), PSTR("<134>%s Tasmota "), NetworkHostname()); +// snprintf_P(header, sizeof(header), PSTR("<%d>%s ESP-"), 128 + min(loglevel * 3, 7), NetworkHostname()); /* RFC3164 - BSD syslog protocol - TIMESTAMP HOSTNAME TAG: MSG = Facility 16 (= local use 0), Severity 6 (= informational) => 16 * 8 + 6 = <134> @@ -2500,11 +2496,7 @@ void SyslogAsync(bool refresh) { */ // snprintf_P(header, sizeof(header), PSTR("<134>%s %s ESP-"), GetSyslogDate(line).c_str(), NetworkHostname()); -// SYSLOG-MSG = <134>Jan 1 00:00:02 wemos5 Tasmota HTP: Web server active on wemos5 with IP address 192.168.2.172 -// Result = 2023-01-01T00:00:02+01:00 wemos5 Tasmota HTP: Web server active on wemos5 with IP address 192.168.2.172 -// snprintf_P(header, sizeof(header), PSTR("<134>%s %s Tasmota "), GetSyslogDate(line).c_str(), NetworkHostname()); - - /* RFC5425 - Syslog protocol - VERSION TIMESTAMP HOSTNAME APP_NAME PROCID STRUCTURED-DATA MSGID MSG + /* RFC5424 - Syslog protocol - VERSION TIMESTAMP HOSTNAME APP_NAME PROCID STRUCTURED-DATA MSGID MSG = Facility 16 (= local use 0), Severity 6 (= informational) => 16 * 8 + 6 = <134> VERSION = 1 TIMESTAMP = yyyy-mm-ddThh:mm:ss.nnnnnn-hh:mm (= local with timezone) @@ -2516,17 +2508,22 @@ void SyslogAsync(bool refresh) { Result = 1970-01-01T00:00:02.096000+00:00 wemos5 Tasmota ESP-HTP: Web server active on wemos5 with IP address 192.168.2.172 Notice date and time is provided by Tasmota device. */ -// char line_time[mxtime]; -// subStr(line_time, line, " ", 1); // 00:00:02.096-026 -// subStr(line_time, line_time, "-", 1); // 00:00:02.096 -// String systime = GetDate() + line_time + "000" + GetTimeZone(); // 1970-01-01T00:00:02.096000+01:00 -// snprintf_P(header, sizeof(header), PSTR("<134>1 %s %s Tasmota - - ESP-"), systime.c_str(), NetworkHostname()); - -// SYSLOG-MSG = <134>1 1970-01-01T00:00:02.096000+01:00 wemos5 Tasmota - - HTP: Web server active on wemos5 with IP address 192.168.2.172 -// Result = 1970-01-01T00:00:02.096000+00:00 wemos5 Tasmota HTP: Web server active on wemos5 with IP address 192.168.2.172 -// snprintf_P(header, sizeof(header), PSTR("<134>1 %s %s Tasmota - - "), systime.c_str(), NetworkHostname()); + char line_time[mxtime]; + subStr(line_time, line, " ", 1); // 00:00:02.096-026 + subStr(line_time, line_time, "-", 1); // 00:00:02.096 + String systime = GetDate() + line_time + "000" + GetTimeZone(); // 1970-01-01T00:00:02.096000+01:00 +// snprintf_P(header, sizeof(header), PSTR("<%d>1 %s %s tasmota - - ESP-"), 128 + min(loglevel * 3, 7), systime.c_str(), NetworkHostname()); + snprintf_P(header, sizeof(header), PSTR("<%d>1 %s %s tasmota - - -"), 128 + min(loglevel * 3, 7), systime.c_str(), NetworkHostname()); char* line_start = line +mxtime; +/* + TasConsole.printf("Header: '"); + TasConsole.printf(header); + TasConsole.printf("', line: '"); + TasConsole.write((uint8_t*)line_start, len -mxtime -1); + TasConsole.printf("'\r\n"); +*/ + #ifdef ESP8266 // Packets over 1460 bytes are not send uint32_t line_len;