Fix syslog message id

This commit is contained in:
Theo Arends 2025-06-10 16:23:42 +02:00
parent bba5ba008e
commit 4002344227
2 changed files with 41 additions and 24 deletions

View File

@ -5,7 +5,7 @@
# Templates # Templates
Find below the available templates as of April 2025. More template information can be found in the [Tasmota Device Templates Repository](http://blakadder.github.io/templates) Find below the available templates as of June 2025. More template information can be found in the [Tasmota Device Templates Repository](http://blakadder.github.io/templates)
## Adapter Board ## Adapter Board
``` ```
@ -403,7 +403,6 @@ Shelly Vintage 4W 260lm 2700k {"NAME":"Shelly Vintage","GPIO":[0,0,0,0,416,0,0,
Shelly Vintage 7W 750lm 2700k {"NAME":"Shelly Vintage","GPIO":[0,0,0,0,416,0,0,0,0,0,0,0,0,0],"FLAG":0,"BASE":18} Shelly Vintage 7W 750lm 2700k {"NAME":"Shelly Vintage","GPIO":[0,0,0,0,416,0,0,0,0,0,0,0,0,0],"FLAG":0,"BASE":18}
Shelly Vintage 7W 750lm 2700k {"NAME":"Shelly Vintage","GPIO":[0,0,0,0,416,0,0,0,0,0,0,0,0,0],"FLAG":0,"BASE":18} Shelly Vintage 7W 750lm 2700k {"NAME":"Shelly Vintage","GPIO":[0,0,0,0,416,0,0,0,0,0,0,0,0,0],"FLAG":0,"BASE":18}
SmartDGM 9W 806lm {"NAME":"L-WB9W1","GPIO":[0,0,0,0,0,416,0,0,160,0,0,0,0,0],"FLAG":0,"BASE":18} SmartDGM 9W 806lm {"NAME":"L-WB9W1","GPIO":[0,0,0,0,0,416,0,0,160,0,0,0,0,0],"FLAG":0,"BASE":18}
Smitch 10W 6500K {"NAME":"Smitch Ambience SB-0110","GPIO":[0,0,0,0,416,0,0,0,0,0,0,0,0,0],"FLAG":0,"BASE":18}
Smitch 10W 6500K {"NAME":"Smitch 10W 6500K Dimmable Bulb (SB0110 - E27)","GPIO":[0,0,0,0,0,416,0,0,0,417,0,0,0,0],"FLAG":0,"BASE":1} Smitch 10W 6500K {"NAME":"Smitch 10W 6500K Dimmable Bulb (SB0110 - E27)","GPIO":[0,0,0,0,0,416,0,0,0,417,0,0,0,0],"FLAG":0,"BASE":1}
TCP Smart 806lm Warm White {"NAME":"TCP Smart Clas","GPIO":[0,0,0,0,0,0,0,0,0,416,0,0,0,0],"FLAG":0,"BASE":1} TCP Smart 806lm Warm White {"NAME":"TCP Smart Clas","GPIO":[0,0,0,0,0,0,0,0,0,416,0,0,0,0],"FLAG":0,"BASE":1}
TCP Smart 810lm Filament {"NAME":"TCP Filament","GPIO":[0,0,0,0,0,0,0,0,0,0,448,0,0,0],"FLAG":0,"BASE":18} TCP Smart 810lm Filament {"NAME":"TCP Filament","GPIO":[0,0,0,0,0,0,0,0,0,0,448,0,0,0],"FLAG":0,"BASE":18}
@ -464,7 +463,7 @@ QS-WiFi-D01-TRIAC 150W {"NAME":"QS-WiFi-D01-TRIAC","GPIO":[0,3200,0,3232,0
RJWF-02A {"NAME":"RJWF-02A","GPIO":[32,2272,0,2304,0,0,0,0,0,0,288,0,0,0],"FLAG":0,"BASE":54} RJWF-02A {"NAME":"RJWF-02A","GPIO":[32,2272,0,2304,0,0,0,0,0,0,288,0,0,0],"FLAG":0,"BASE":54}
Shelly Dimmer {"NAME":"Shelly Dimmer 1","GPIO":[0,3200,0,3232,5568,5600,0,0,192,0,193,288,0,4736],"FLAG":0,"BASE":18} Shelly Dimmer {"NAME":"Shelly Dimmer 1","GPIO":[0,3200,0,3232,5568,5600,0,0,192,0,193,288,0,4736],"FLAG":0,"BASE":18}
Shelly Dimmer 2 {"NAME":"Shelly Dimmer 2","GPIO":[0,3200,0,3232,5568,5600,0,0,193,0,192,0,320,4736],"FLAG":0,"BASE":18} Shelly Dimmer 2 {"NAME":"Shelly Dimmer 2","GPIO":[0,3200,0,3232,5568,5600,0,0,193,0,192,0,320,4736],"FLAG":0,"BASE":18}
Shelly Plus 0-10V Dimmer {"NAME":"Shelly Plus 0-10V Dimmer","GPIO":[288,0,0,0,192,0,0,0,0,0,0,0,0,0,193,1,0,0,0,0,0,32,416,0,0,0,0,0,4736,0,0,0,0,0,0,0],"FLAG":0,"BASE":1} Shelly Plus 0-10V Dimmer {"NAME":"Shelly Plus 0-10V Dimmer","GPIO":[288,0,0,0,192,0,0,0,0,0,0,0,0,0,193,1,0,0,0,0,0,32,448,0,0,0,0,0,4736,0,0,0,0,0,0,0],"FLAG":0,"BASE":1}
Sonoff D1 {"NAME":"Sonoff D1","GPIO":[1,3200,0,3232,0,0,0,0,0,320,0,0,0,0],"FLAG":0,"BASE":74} Sonoff D1 {"NAME":"Sonoff D1","GPIO":[1,3200,0,3232,0,0,0,0,0,320,0,0,0,0],"FLAG":0,"BASE":74}
``` ```

View File

@ -2462,7 +2462,7 @@ void SyslogAsync(bool refresh) {
return; return;
} }
char header[100]; char header[128];
/* Legacy format (until v13.3.0.1) - HOSTNAME TAG: MSG /* 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 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 Result = 2023-12-20T13:41:11.825749+01:00 wemos5 ESP-HTP: Web server active on wemos5 with IP address 192.168.2.172
@ -2496,49 +2496,67 @@ void SyslogAsync(bool refresh) {
*/ */
// snprintf_P(header, sizeof(header), PSTR("<134>%s %s ESP-"), GetSyslogDate(line).c_str(), NetworkHostname()); // snprintf_P(header, sizeof(header), PSTR("<134>%s %s ESP-"), GetSyslogDate(line).c_str(), NetworkHostname());
char* msg_start = line +mxtime;
uint32_t msg_len = len -mxtime -1;
/* RFC5424 - Syslog protocol - <PRI>VERSION TIMESTAMP HOSTNAME APP_NAME PROCID STRUCTURED-DATA MSGID MSG /* RFC5424 - Syslog protocol - <PRI>VERSION TIMESTAMP HOSTNAME APP_NAME PROCID STRUCTURED-DATA MSGID MSG
<PRI> = Facility 16 (= local use 0), Severity 6 (= informational) => 16 * 8 + 6 = <134> <PRI> = Facility 16 (= local use 0), Severity 6 (= informational) => 16 * 8 + 6 = <134>
VERSION = 1 VERSION = 1
TIMESTAMP = yyyy-mm-ddThh:mm:ss.nnnnnn-hh:mm (= local with timezone) TIMESTAMP = yyyy-mm-ddThh:mm:ss.nnnnnn-hh:mm (= local with timezone)
APP_NAME = Tasmota APP_NAME = tasmota
PROCID = - PROCID = -
STRUCTURED-DATA = - STRUCTURED-DATA = -
MSGID = ESP-HTP: MSGID = HTP:
SYSLOG-MSG = <134>1 1970-01-01T00:00:02.096000+01:00 wemos5 Tasmota - - ESP-HTP: Web server active on wemos5 with IP address 192.168.2.172 SYSLOG-MSG = <134>1 1970-01-01T00:00:02.096000+01:00 wemos5 Tasmota - - ESP-HTP: Web server active on wemos5 with IP address 192.168.2.172
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 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. Notice date and time is provided by Tasmota device.
*/ */
char line_time[mxtime]; char timestamp[mxtime];
subStr(line_time, line, " ", 1); // 00:00:02.096-026 subStr(timestamp, line, " ", 1); // 00:00:02.096-026
subStr(line_time, line_time, "-", 1); // 00:00:02.096 subStr(timestamp, timestamp, "-", 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: '"); snprintf_P(header, sizeof(header), PSTR("<%d>1 %s%s000%s %s tasmota - - -"),
128 + min(loglevel * 3, 7),
GetDate().c_str(), timestamp, GetTimeZone().c_str(), // 1970-01-01T00:00:02.096000+01:00
NetworkHostname());
*/
char msgid[5];
char* line_msgid = strchr(msg_start, ' ');
if (line_msgid - msg_start < sizeof(msgid)) { // Only 3 character message ids supported
subStr(msgid, msg_start, " ", 1); // HTP:
msg_start += strlen(msgid);
msg_len -= strlen(msgid);
} else {
strcpy(msgid, "-"); // -
}
snprintf_P(header, sizeof(header), PSTR("<%d>1 %s%s000%s %s tasmota - - %s"),
128 + min(loglevel * 3, 7), // Error (1) = 131, Info (2) = 134, Debug (3) = 135, DebugMore = (4) 135
GetDate().c_str(), timestamp, GetTimeZone().c_str(), // 1970-01-01T00:00:02.096000+01:00
NetworkHostname(), msgid);
/*
TasConsole.printf("Loglevel ");
TasConsole.print(loglevel);
TasConsole.printf(", Header '");
TasConsole.printf(header); TasConsole.printf(header);
TasConsole.printf("', line: '"); TasConsole.printf("', Msg '");
TasConsole.write((uint8_t*)line_start, len -mxtime -1); TasConsole.write((uint8_t*)msg_start, msg_len);
TasConsole.printf("'\r\n"); TasConsole.printf("'\r\n");
*/ */
#ifdef ESP8266 #ifdef ESP8266
// Packets over 1460 bytes are not send // Packets over 1460 bytes are not send
uint32_t line_len; uint32_t package_len;
int32_t log_len = len -mxtime -1; int32_t log_len = msg_len;
while (log_len > 0) { while (log_len > 0) {
PortUdp.write(header); PortUdp.write(header);
line_len = (log_len > 1460) ? 1460 : log_len; package_len = (log_len > 1460) ? 1460 : log_len;
PortUdp.write((uint8_t*)line_start, line_len); PortUdp.write((uint8_t*)msg_start, package_len);
PortUdp.endPacket(); PortUdp.endPacket();
log_len -= 1460; log_len -= 1460;
line_start += 1460; msg_start += 1460;
} }
#else #else
PortUdp.write((const uint8_t*)header, strlen(header)); PortUdp.write((const uint8_t*)header, strlen(header));
PortUdp.write((uint8_t*)line_start, len -mxtime -1); PortUdp.write((uint8_t*)msg_start, msg_len);
PortUdp.endPacket(); PortUdp.endPacket();
#endif #endif