From 25c4c5b7b83a3d29eea38c355dc2202081d3d452 Mon Sep 17 00:00:00 2001 From: KrX3D Date: Fri, 25 Apr 2025 19:46:41 +0200 Subject: [PATCH 01/19] add syslog function to wled --- wled00/bus_manager.h | 5 +- wled00/cfg.cpp | 20 ++++ wled00/data/settings_sync.htm | 53 +++++++++ wled00/json.cpp | 8 +- wled00/set.cpp | 22 ++++ wled00/syslog.cpp | 200 ++++++++++++++++++++++++++++++++++ wled00/syslog.h | 83 ++++++++++++++ wled00/wled.cpp | 11 +- wled00/wled.h | 28 ++++- wled00/xml.cpp | 14 ++- 10 files changed, 438 insertions(+), 6 deletions(-) create mode 100644 wled00/syslog.cpp create mode 100644 wled00/syslog.h diff --git a/wled00/bus_manager.h b/wled00/bus_manager.h index 0570cc2d6c..b72560cddd 100644 --- a/wled00/bus_manager.h +++ b/wled00/bus_manager.h @@ -24,7 +24,10 @@ make_unique(Args&&... args) #endif // enable additional debug output -#if defined(WLED_DEBUG_HOST) +#if defined(WLED_ENABLE_SYSLOG) + #include "syslog.h" + #define DEBUGOUT Syslog +#elif defined(WLED_DEBUG_HOST) #include "net_debug.h" #define DEBUGOUT NetDebug #else diff --git a/wled00/cfg.cpp b/wled00/cfg.cpp index fa0397fc65..0d93fc1eb3 100644 --- a/wled00/cfg.cpp +++ b/wled00/cfg.cpp @@ -536,6 +536,16 @@ bool deserializeConfig(JsonObject doc, bool fromFS) { CJSON(hueIP[i], if_hue_ip[i]); #endif +#ifdef WLED_ENABLE_SYSLOG + JsonObject if_syslog = interfaces["syslog"]; + CJSON(syslogEnabled, if_syslog["en"]); + getStringFromJson(syslogHost, if_syslog[F("host")], 33); + CJSON(syslogPort, if_syslog["port"]); + CJSON(syslogProtocol, if_syslog["proto"]); + CJSON(syslogFacility, if_syslog["fac"]); + CJSON(syslogSeverity, if_syslog["sev"]); +#endif + JsonObject if_ntp = interfaces[F("ntp")]; CJSON(ntpEnabled, if_ntp["en"]); getStringFromJson(ntpServerName, if_ntp[F("host")], 33); // "1.wled.pool.ntp.org" @@ -1051,6 +1061,16 @@ void serializeConfig(JsonObject root) { } #endif +#ifdef WLED_ENABLE_SYSLOG + JsonObject if_syslog = interfaces.createNestedObject("syslog"); + if_syslog["en"] = syslogEnabled; + if_syslog["host"] = syslogHost; + if_syslog["port"] = syslogPort; + if_syslog["proto"] = syslogProtocol; + if_syslog["fac"] = syslogFacility; + if_syslog["sev"] = syslogSeverity; +#endif + JsonObject if_ntp = interfaces.createNestedObject("ntp"); if_ntp["en"] = ntpEnabled; if_ntp[F("host")] = ntpServerName; diff --git a/wled00/data/settings_sync.htm b/wled00/data/settings_sync.htm index ca6c0fb59c..e0ec292f05 100644 --- a/wled00/data/settings_sync.htm +++ b/wled00/data/settings_sync.htm @@ -237,6 +237,59 @@

Serial


Keep at 115200 to use Improv. Some boards may not support high rates. +

Syslog

+
+ This firmware build does not support Syslog interface.
+
+
+Enable Syslog:
+Host:
+Port:
+Protocol: +
+Facility: +
+Severity: +
+

diff --git a/wled00/json.cpp b/wled00/json.cpp index c09b543f1c..6b51a95d38 100644 --- a/wled00/json.cpp +++ b/wled00/json.cpp @@ -298,7 +298,10 @@ bool deserializeState(JsonObject root, byte callMode, byte presetId) bool stateResponse = root[F("v")] | false; #if defined(WLED_DEBUG) && defined(WLED_DEBUG_HOST) - netDebugEnabled = root[F("debug")] | netDebugEnabled; + netDebugEnabled = root[F("debug")] | netDebugEnabled; + #elif defined(WLED_DEBUG) && defined(WLED_ENABLE_SYSLOG) + syslogEnabled = root[F("debug")] | syslogEnabled; + DEBUG_PRINTF_P(PSTR("Syslog: %s\n"), syslogEnabled ? PSTR("ENABLED") : PSTR("DISABLED") ); #endif bool onBefore = bri; @@ -781,6 +784,9 @@ void serializeInfo(JsonObject root) #ifdef WLED_DEBUG_HOST os |= 0x0100; if (!netDebugEnabled) os &= ~0x0080; + #elif defined(WLED_ENABLE_SYSLOG) + os |= 0x0100; + if (!syslogEnabled) os &= ~0x0080; #endif #endif #ifndef WLED_DISABLE_ALEXA diff --git a/wled00/set.cpp b/wled00/set.cpp index 725875023e..f20ea38401 100644 --- a/wled00/set.cpp +++ b/wled00/set.cpp @@ -472,6 +472,28 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage) t = request->arg(F("BD")).toInt(); if (t >= 96 && t <= 15000) serialBaud = t; updateBaudRate(serialBaud *100); + + #ifdef WLED_ENABLE_SYSLOG + syslogEnabled = request->hasArg(F("SL_en")); + strlcpy(syslogHost, request->arg(F("SL_host")).c_str(), sizeof(syslogHost)); + + t = request->arg(F("SL_port")).toInt(); + if (t > 0) syslogPort = t; + + t = request->arg(F("SL_proto")).toInt(); + if (t >= SYSLOG_PROTO_BSD && t <= SYSLOG_PROTO_RAW) syslogProtocol = t; + + t = request->arg(F("SL_fac")).toInt(); + if (t >= SYSLOG_KERN && t <= SYSLOG_LOCAL7) syslogFacility = t; + + t = request->arg(F("SL_sev")).toInt(); + if (t >= SYSLOG_EMERG && t <= SYSLOG_DEBUG) syslogSeverity = t; + + Syslog.begin(syslogHost, syslogPort, + syslogFacility, syslogSeverity, syslogProtocol); + + Syslog.setAppName("WLED"); + #endif } //TIME diff --git a/wled00/syslog.cpp b/wled00/syslog.cpp new file mode 100644 index 0000000000..06d85b5d69 --- /dev/null +++ b/wled00/syslog.cpp @@ -0,0 +1,200 @@ +#include "wled.h" +#ifdef WLED_ENABLE_SYSLOG + +#include "syslog.h" + +static const __FlashStringHelper* protoNames[] = { F("BSD"), F("RFC5424"), F("RAW") }; +static const char* facilityNames[] = { + "KERN", "USER", "MAIL", "DAEM", + "AUTH", "SYSL", "LPR", "NEWS", + "UUCP", "CRON", "APRV", "FTP", + "NTP", "AUDT", "ALRT", "CLCK", + "LCL0", "LCL1", "LCL2", "LCL3", + "LCL4", "LCL5", "LCL6", "LCL7" +}; + +static const char* severityNames[] = { + "EMERG","ALERT","CRIT","ERR","WARNING","NOTICE","INFO","DEBUG" +}; + +SyslogPrinter::SyslogPrinter() : + _facility(SYSLOG_LOCAL4), + _severity(SYSLOG_DEBUG), + _protocol(SYSLOG_PROTO_BSD), + _appName("WLED"), + _bufferIndex(0) {} + +void SyslogPrinter::begin(const char* host, uint16_t port, + uint8_t facility, uint8_t severity, uint8_t protocol) { + + DEBUG_PRINTF_P(PSTR("===== WLED SYSLOG CONFIGURATION =====\n")); + DEBUG_PRINTF_P(PSTR(" Hostname: %s\n"), syslogHost); + DEBUG_PRINTF_P(PSTR(" Cached IP: %s\n"), syslogHostIP.toString().c_str()); + DEBUG_PRINTF_P(PSTR(" Port: %u\n"), (unsigned)syslogPort); + DEBUG_PRINTF_P(PSTR(" Protocol: %u (%s)\n"), + protocol, + protocol <= 2 ? (const char*)protoNames[protocol] : "UNKNOWN" + ); + DEBUG_PRINTF_P(PSTR(" Facility: %u (%s)\n"), + (unsigned)facility, + (facility < sizeof(facilityNames)/sizeof(facilityNames[0])) + ? facilityNames[facility] + : PSTR("UNKNOWN")); + DEBUG_PRINTF_P(PSTR(" Severity: %u (%s)\n"), + (unsigned)severity, + (severity < sizeof(severityNames)/sizeof(severityNames[0])) + ? severityNames[severity] + : PSTR("UNKNOWN")); + DEBUG_PRINTF_P(PSTR("======================================\n")); + + strlcpy(syslogHost, host, sizeof(syslogHost)); + syslogPort = port; + _facility = facility; + _severity = severity; + _protocol = protocol; + + // clear any cached IP so resolveHostname() will run next write() + syslogHostIP = IPAddress(0,0,0,0); +} + +void SyslogPrinter::setAppName(const String &appName) { + _appName = appName; +} + +bool SyslogPrinter::resolveHostname() { + if (!WLED_CONNECTED || !syslogEnabled) return false; + + // If we already have an IP or can parse the hostname as an IP, use that + if (syslogHostIP || syslogHostIP.fromString(syslogHost)) { + return true; + } + + // Otherwise resolve the hostname + #ifdef ESP8266 + WiFi.hostByName(syslogHost, syslogHostIP, 750); + #else + #ifdef WLED_USE_ETHERNET + ETH.hostByName(syslogHost, syslogHostIP); + #else + WiFi.hostByName(syslogHost, syslogHostIP); + #endif + #endif + + return syslogHostIP != IPAddress(0, 0, 0, 0); +} + +void SyslogPrinter::flushBuffer() { + if (_bufferIndex == 0) return; + + // Trim any trailing CR so syslog server won’t show “#015” + if (_bufferIndex > 0 && _buffer[_bufferIndex-1] == '\r') _bufferIndex--; + + // Null-terminate + _buffer[_bufferIndex] = '\0'; + + // Send the buffer with default severity + write((const uint8_t*)_buffer, _bufferIndex, _severity); + + // Reset buffer index + _bufferIndex = 0; +} + +size_t SyslogPrinter::write(uint8_t c) { + // Store in buffer regardless of connection status + if (_bufferIndex < sizeof(_buffer) - 1) { + _buffer[_bufferIndex++] = c; + } + + // If newline or buffer full, flush + if (c == '\n' || _bufferIndex >= sizeof(_buffer) - 1) { + flushBuffer(); + } + + return 1; +} + +size_t SyslogPrinter::write(const uint8_t *buf, size_t size) { + return write(buf, size, _severity); +} + +size_t SyslogPrinter::write(const uint8_t *buf, size_t size, uint8_t severity) { + if (!WLED_CONNECTED || buf == nullptr || !syslogEnabled) return 0; + if (!resolveHostname()) return 0; + + syslogUdp.beginPacket(syslogHostIP, syslogPort); + + // Calculate priority value + uint8_t pri = (_facility << 3) | severity; + + // Handle different syslog protocol formats + switch (_protocol) { + case SYSLOG_PROTO_BSD: + // RFC 3164 format: TIMESTAMP HOSTNAME APP-NAME: MESSAGE + syslogUdp.printf("<%d>", pri); + + if (ntpEnabled && ntpConnected) { + // Month abbreviation + const char* months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", + "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; + + syslogUdp.printf("%s %2d %02d:%02d:%02d ", + months[month(localTime) - 1], + day(localTime), + hour(localTime), + minute(localTime), + second(localTime)); + } else { + // No valid time available + syslogUdp.print("Jan 01 00:00:00 "); + } + + // Add hostname and app name + syslogUdp.print(serverDescription); + syslogUdp.print(" "); + syslogUdp.print(_appName); + syslogUdp.print(": "); + + // Add message content + size = syslogUdp.write(buf, size); + break; + + case SYSLOG_PROTO_RFC5424: + // RFC 5424 format: VERSION TIMESTAMP HOSTNAME APP-NAME PROCID MSGID STRUCTURED-DATA MSG + syslogUdp.printf("<%d>1 ", pri); // Version is always 1 + + if (ntpEnabled && ntpConnected) { + syslogUdp.printf("%04d-%02d-%02dT%02d:%02d:%02dZ ", + year(localTime), + month(localTime), + day(localTime), + hour(localTime), + minute(localTime), + second(localTime)); + } else { + // No valid time available + syslogUdp.print("1970-01-01T00:00:00Z "); + } + + // Add hostname, app name, and other fields (using - for empty fields) + syslogUdp.print(serverDescription); + syslogUdp.print(" "); + syslogUdp.print(_appName); + syslogUdp.print(" - - - "); // PROCID, MSGID, and STRUCTURED-DATA are empty + + // Add message content + size = syslogUdp.write(buf, size); + break; + + case SYSLOG_PROTO_RAW: + default: + // Just send the raw message (like original NetDebug) + size = syslogUdp.write(buf, size); + break; + } + + syslogUdp.endPacket(); + return size; +} + +SyslogPrinter Syslog; +#endif // WLED_ENABLE_SYSLOG \ No newline at end of file diff --git a/wled00/syslog.h b/wled00/syslog.h new file mode 100644 index 0000000000..25ec1930e7 --- /dev/null +++ b/wled00/syslog.h @@ -0,0 +1,83 @@ +#ifndef WLED_SYSLOG_H +#define WLED_SYSLOG_H +#include +#include + +// Syslog facility codes +#define SYSLOG_KERN 0 // kernel messages +#define SYSLOG_USER 1 // user-level messages +#define SYSLOG_MAIL 2 // mail system +#define SYSLOG_DAEMON 3 // system daemons +#define SYSLOG_AUTH 4 // security/authorization messages +#define SYSLOG_SYSLOG 5 // messages generated internally by syslogd +#define SYSLOG_LPR 6 // line printer subsystem +#define SYSLOG_NEWS 7 // network news subsystem +#define SYSLOG_UUCP 8 // UUCP subsystem +#define SYSLOG_CRON 9 // clock daemon +#define SYSLOG_AUTHPRIV 10 // security/authorization messages (private) +#define SYSLOG_FTP 11 // FTP daemon +#define SYSLOG_NTP 12 // NTP subsystem (used in some systems) +#define SYSLOG_LOG_AUDIT 13 // log audit (used in some systems like Linux auditd) +#define SYSLOG_LOG_ALERT 14 // log alert +#define SYSLOG_CLOCK_DAEMON 15 // clock daemon (alternate) +#define SYSLOG_LOCAL0 16 // local use 0 +#define SYSLOG_LOCAL1 17 // local use 1 +#define SYSLOG_LOCAL2 18 // local use 2 +#define SYSLOG_LOCAL3 19 // local use 3 +#define SYSLOG_LOCAL4 20 // local use 4 +#define SYSLOG_LOCAL5 21 // local use 5 +#define SYSLOG_LOCAL6 22 // local use 6 +#define SYSLOG_LOCAL7 23 // local use 7 + +// Syslog severity levels +#define SYSLOG_EMERG 0 // Emergency: system is unusable +#define SYSLOG_ALERT 1 // Alert: action must be taken immediately +#define SYSLOG_CRIT 2 // Critical: critical conditions +#define SYSLOG_ERR 3 // Error: error conditions +#define SYSLOG_WARNING 4 // Warning: warning conditions +#define SYSLOG_NOTICE 5 // Notice: normal but significant condition +#define SYSLOG_INFO 6 // Informational: informational messages +#define SYSLOG_DEBUG 7 // Debug: debug-level messages + +// Syslog protocol formats +#define SYSLOG_PROTO_BSD 0 // Legacy BSD format (RFC 3164) +#define SYSLOG_PROTO_RFC5424 1 // Modern syslog format (RFC 5424) +#define SYSLOG_PROTO_RAW 2 // Raw text (like original NetDebug) + +class SyslogPrinter : public Print { + private: + WiFiUDP syslogUdp; // needs to be here otherwise UDP messages get truncated upon destruction + IPAddress syslogHostIP; + bool resolveHostname(); + + // Syslog configuration + uint8_t _facility; + uint8_t _severity; + uint8_t _protocol; + String _appName; + bool test = true; + // Buffer management + char _buffer[128]; // Buffer for collecting characters + size_t _bufferIndex; + void flushBuffer(); + + public: + SyslogPrinter(); + void begin(const char* host, uint16_t port, + uint8_t facility = SYSLOG_LOCAL4, + uint8_t severity = SYSLOG_DEBUG, + uint8_t protocol = SYSLOG_PROTO_BSD); + void setAppName(const String &appName); + + // Print interface implementation + virtual size_t write(uint8_t c); + virtual size_t write(const uint8_t *buf, size_t size); + + // Severity override for specific messages + size_t write(const uint8_t *buf, size_t size, uint8_t severity); +}; + +// Default instance +extern SyslogPrinter Syslog; + +#endif \ No newline at end of file diff --git a/wled00/wled.cpp b/wled00/wled.cpp index cc338d23f2..97d092ba61 100644 --- a/wled00/wled.cpp +++ b/wled00/wled.cpp @@ -329,7 +329,7 @@ void WLED::setup() #if defined(WLED_DEBUG) && defined(ARDUINO_ARCH_ESP32) && (defined(CONFIG_IDF_TARGET_ESP32S2) || defined(CONFIG_IDF_TARGET_ESP32C3) || ARDUINO_USB_CDC_ON_BOOT) delay(2500); // allow CDC USB serial to initialise #endif - #if !defined(WLED_DEBUG) && defined(ARDUINO_ARCH_ESP32) && !defined(WLED_DEBUG_HOST) && ARDUINO_USB_CDC_ON_BOOT + #if !defined(WLED_DEBUG) && defined(ARDUINO_ARCH_ESP32) && !defined(WLED_DEBUG_HOST) && !defined(WLED_ENABLE_SYSLOG) && ARDUINO_USB_CDC_ON_BOOT Serial.setDebugOutput(false); // switch off kernel messages when using USBCDC #endif DEBUG_PRINTLN(); @@ -387,7 +387,7 @@ void WLED::setup() usePWMFixedNMI(); // link the NMI fix #endif -#if defined(WLED_DEBUG) && !defined(WLED_DEBUG_HOST) +#if defined(WLED_DEBUG) && !defined(WLED_DEBUG_HOST) && !defined(WLED_ENABLE_SYSLOG) PinManager::allocatePin(hardwareTX, true, PinOwner::DebugOut); // TX (GPIO1 on ESP32) reserved for debug output #endif #ifdef WLED_ENABLE_DMX //reserve GPIO2 as hardcoded DMX pin @@ -422,6 +422,13 @@ void WLED::setup() WLED_SET_AP_SSID(); // otherwise it is empty on first boot until config is saved multiWiFi.push_back(WiFiConfig(CLIENT_SSID,CLIENT_PASS)); // initialise vector with default WiFi +#ifdef WLED_ENABLE_SYSLOG + // Configure and initialize Syslog client + Syslog.begin(syslogHost, syslogPort, + syslogFacility, syslogSeverity, syslogProtocol); + Syslog.setAppName("WLED"); +#endif + DEBUG_PRINTLN(F("Reading config")); deserializeConfigFromFS(); DEBUG_PRINTF_P(PSTR("heap %u\n"), ESP.getFreeHeap()); diff --git a/wled00/wled.h b/wled00/wled.h index f8dc1252a8..da8007caca 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -964,7 +964,33 @@ WLED_GLOBAL JsonDocument *pDoc _INIT(&gDoc); WLED_GLOBAL volatile uint8_t jsonBufferLock _INIT(0); // enable additional debug output -#if defined(WLED_DEBUG_HOST) +#if defined(WLED_ENABLE_SYSLOG) + #include "syslog.h" + // On the host side, use a standard syslog server or tools like rsyslog + // use -D WLED_ENABLE_SYSLOG and -D WLED_DEBUG + #define DEBUGOUT Syslog + WLED_GLOBAL bool syslogEnabled _INIT(true); + #ifndef WLED_SYSLOG_HOST + #define WLED_SYSLOG_HOST "" + #endif + WLED_GLOBAL char syslogHost[33] _INIT(WLED_SYSLOG_HOST); + #ifndef WLED_SYSLOG_PORT + #define WLED_SYSLOG_PORT 514 + #endif + WLED_GLOBAL int syslogPort _INIT(WLED_SYSLOG_PORT); + #ifndef WLED_SYSLOG_PROTOCOL + #define WLED_SYSLOG_PROTOCOL SYSLOG_PROTO_BSD + #endif + WLED_GLOBAL uint8_t syslogProtocol _INIT(WLED_SYSLOG_PROTOCOL); + #ifndef WLED_SYSLOG_FACILITY + #define WLED_SYSLOG_FACILITY SYSLOG_LOCAL4 + #endif + WLED_GLOBAL uint8_t syslogFacility _INIT(WLED_SYSLOG_FACILITY); + #ifndef WLED_SYSLOG_SEVERITY + #define WLED_SYSLOG_SEVERITY SYSLOG_DEBUG + #endif + WLED_GLOBAL uint8_t syslogSeverity _INIT(WLED_SYSLOG_SEVERITY); +#elif defined(WLED_DEBUG_HOST) #include "net_debug.h" // On the host side, use netcat to receive the log statements: nc -l 7868 -u // use -D WLED_DEBUG_HOST='"192.168.xxx.xxx"' or FQDN within quotes diff --git a/wled00/xml.cpp b/wled00/xml.cpp index de2f5590df..ff1b5f0daf 100644 --- a/wled00/xml.cpp +++ b/wled00/xml.cpp @@ -105,7 +105,7 @@ void appendGPIOinfo(Print& settingsScript) { settingsScript.print(2); // DMX hardcoded pin firstPin = false; #endif - #if defined(WLED_DEBUG) && !defined(WLED_DEBUG_HOST) + #if defined(WLED_DEBUG) && !defined(WLED_DEBUG_HOST) && !defined(WLED_ENABLE_SYSLOG) if (!firstPin) settingsScript.print(','); settingsScript.print(hardwareTX); // debug output (TX) pin firstPin = false; @@ -516,6 +516,18 @@ void getSettingsJS(byte subPage, Print& settingsScript) settingsScript.print(F("toggle('Hue');")); // hide Hue Sync settings #endif printSetFormValue(settingsScript,PSTR("BD"),serialBaud); + + #ifdef WLED_ENABLE_SYSLOG + printSetFormCheckbox(settingsScript,PSTR("SL_en"), syslogEnabled); // enable/disable + printSetFormValue (settingsScript,PSTR("SL_host"), syslogHost); // host + printSetFormValue (settingsScript,PSTR("SL_port"), syslogPort); // port + printSetFormValue (settingsScript,PSTR("SL_proto"), syslogProtocol); // protocol + printSetFormValue (settingsScript,PSTR("SL_fac"), syslogFacility); // facility + printSetFormValue (settingsScript,PSTR("SL_sev"), syslogSeverity); // severity + #else + settingsScript.print(F("toggle('Syslog');")); // hide Syslog Sync settings + #endif + #ifndef WLED_ENABLE_ADALIGHT settingsScript.print(F("toggle('Serial');")); #endif From afccadd850f5c736611372fdabb613f6d525c6d4 Mon Sep 17 00:00:00 2001 From: KrX3D Date: Sat, 26 Apr 2025 15:03:14 +0200 Subject: [PATCH 02/19] Update wled00/syslog.cpp Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> --- wled00/syslog.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/wled00/syslog.cpp b/wled00/syslog.cpp index 06d85b5d69..c16b94f9ca 100644 --- a/wled00/syslog.cpp +++ b/wled00/syslog.cpp @@ -22,7 +22,9 @@ SyslogPrinter::SyslogPrinter() : _severity(SYSLOG_DEBUG), _protocol(SYSLOG_PROTO_BSD), _appName("WLED"), - _bufferIndex(0) {} + _bufferIndex(0), + _lastOperationSucceeded(true), + _lastErrorMessage("") {} void SyslogPrinter::begin(const char* host, uint16_t port, uint8_t facility, uint8_t severity, uint8_t protocol) { From a48b05ea3876fccaf864032b6224af017017478d Mon Sep 17 00:00:00 2001 From: KrX3D Date: Sat, 26 Apr 2025 15:11:25 +0200 Subject: [PATCH 03/19] added coderabbitai suggestions like: - Add error state tracking to the SyslogPrinter class. - configurable buffer size. That way, anyone can -D SYSLOG_BUFFER_SIZE=256 (or larger) in their build flags to avoid silent truncation. --- wled00/syslog.cpp | 23 +++++++++++++++++++++-- wled00/syslog.h | 14 ++++++++++++-- 2 files changed, 33 insertions(+), 4 deletions(-) diff --git a/wled00/syslog.cpp b/wled00/syslog.cpp index c16b94f9ca..7a46a66e80 100644 --- a/wled00/syslog.cpp +++ b/wled00/syslog.cpp @@ -120,8 +120,27 @@ size_t SyslogPrinter::write(const uint8_t *buf, size_t size) { } size_t SyslogPrinter::write(const uint8_t *buf, size_t size, uint8_t severity) { - if (!WLED_CONNECTED || buf == nullptr || !syslogEnabled) return 0; - if (!resolveHostname()) return 0; + _lastOperationSucceeded = true; + if (!WLED_CONNECTED) { + _lastOperationSucceeded = false; + _lastErrorMessage = F("Network not connected"); + return 0; + } + if (buf == nullptr) { + _lastOperationSucceeded = false; + _lastErrorMessage = F("Null buffer provided"); + return 0; + } + if (!syslogEnabled) { + _lastOperationSucceeded = false; + _lastErrorMessage = F("Syslog is disabled"); + return 0; + } + if (!resolveHostname()) { + _lastOperationSucceeded = false; + _lastErrorMessage = F("Failed to resolve hostname"); + return 0; + } syslogUdp.beginPacket(syslogHostIP, syslogPort); diff --git a/wled00/syslog.h b/wled00/syslog.h index 25ec1930e7..9031da6b23 100644 --- a/wled00/syslog.h +++ b/wled00/syslog.h @@ -49,15 +49,21 @@ class SyslogPrinter : public Print { WiFiUDP syslogUdp; // needs to be here otherwise UDP messages get truncated upon destruction IPAddress syslogHostIP; bool resolveHostname(); + bool _lastOperationSucceeded; + String _lastErrorMessage; // Syslog configuration uint8_t _facility; uint8_t _severity; uint8_t _protocol; String _appName; - bool test = true; + // Buffer management - char _buffer[128]; // Buffer for collecting characters + #ifndef SYSLOG_BUFFER_SIZE + #define SYSLOG_BUFFER_SIZE 128 + #endif + char _buffer[SYSLOG_BUFFER_SIZE]; // Buffer for collecting characters + size_t _bufferIndex; void flushBuffer(); @@ -75,6 +81,10 @@ class SyslogPrinter : public Print { // Severity override for specific messages size_t write(const uint8_t *buf, size_t size, uint8_t severity); + + // Error handling + bool lastOperationSucceeded() const { return _lastOperationSucceeded; } + String getLastErrorMessage() const { return _lastErrorMessage; } }; // Default instance From 070b6b2d9ff3f89c73d446595cfd79adb5b6efe9 Mon Sep 17 00:00:00 2001 From: KrX3D Date: Sat, 26 Apr 2025 23:52:03 +0200 Subject: [PATCH 04/19] inject html to settings_sync.htm only when syslog enabled to save size to all builds --- pio-scripts/inject_syslog_ui.py | 171 ++++++++++++++++++++++++++++++++ platformio.ini | 1 + wled00/data/settings_sync.htm | 54 +--------- 3 files changed, 173 insertions(+), 53 deletions(-) create mode 100644 pio-scripts/inject_syslog_ui.py diff --git a/pio-scripts/inject_syslog_ui.py b/pio-scripts/inject_syslog_ui.py new file mode 100644 index 0000000000..03c208c5f8 --- /dev/null +++ b/pio-scripts/inject_syslog_ui.py @@ -0,0 +1,171 @@ +# pio-scripts/inject_syslog_ui.py +import os, shutil, sys +from SCons.Script import Import + +Import("env") + +# detect full vs. partial compile +is_full_build = env.get("PIOENV") is not None + +# Track the state between builds +def get_previous_syslog_state(project_dir): + state_file = os.path.join(project_dir, "wled00/data/.syslog_state") + if os.path.exists(state_file): + with open(state_file, 'r') as f: + return f.read().strip() == "1" + return None # None means no previous state recorded + +def set_syslog_state(project_dir, enabled): + state_file = os.path.join(project_dir, "wled00/data/.syslog_state") + with open(state_file, 'w') as f: + f.write("1" if enabled else "0") + +# This is the HTML we want to inject +SYSLOG_HTML = """ +

Syslog

+
+ This firmware build does not support Syslog interface.
+
+
+ Enable Syslog:
+ Host:
+ Port:
+ Protocol: +
+ Facility: +
+ Severity: +
+
+""" + +def inject_syslog_ui(source, target, env): + print("\033[44m==== inject_syslog_ui.py (PRE BUILD) ====\033[0m") + if not is_full_build: + print("\033[43mNot a full build, skipping Syslog UI operations.\033[0m") + return + + # Check for the define in BUILD_FLAGS + build_flags = env.get("BUILD_FLAGS", "") + if isinstance(build_flags, list): + build_flags = " ".join(build_flags) + has_syslog = ("-D WLED_ENABLE_SYSLOG" in build_flags or "-DWLED_ENABLE_SYSLOG" in build_flags) + + project_dir = env.subst("$PROJECT_DIR") + html_path = os.path.join(project_dir, "wled00/data/settings_sync.htm") + bak = html_path + ".backup" + + # Detect state change → touch to force rebuild + prev = get_previous_syslog_state(project_dir) + if prev is not None and prev != has_syslog: + print(f"\033[43mSYSLOG state changed from {prev} to {has_syslog}, forcing UI rebuild.\033[0m") + if os.path.exists(html_path): + with open(html_path, 'a'): + os.utime(html_path, None) + + set_syslog_state(project_dir, has_syslog) + + if not has_syslog: + print("\033[43mWLED_ENABLE_SYSLOG not defined, skipping injection.\033[0m") + # restore if backup exists + if os.path.exists(bak): + print("Restoring original file from backup...") + shutil.copy2(bak, html_path) + os.remove(bak) + return + + # backup + inject only once + if not os.path.exists(bak): + print("Backing up and injecting Syslog UI...") + shutil.copyfile(html_path, bak) + try: + original = open(html_path, 'r', encoding='utf8').read() + modified = original + + # replace existing section if present + if '' in modified and '' in modified: + start = modified.index('') + end = modified.index('') + len('') + modified = ( + modified[:start] + + '\n' + SYSLOG_HTML + '\n' + + modified[end:] + ) + else: + # insert before last
+ idx = modified.rfind('
') + if idx == -1: + print("\033[41mCould not find
to insert Syslog UI!\033[0m") + return + modified = ( + modified[:idx] + + '\n' + SYSLOG_HTML + '\n\n' + + modified[idx:] + ) + + with open(html_path, 'w', encoding='utf8') as f: + f.write(modified) + print("\033[42mSyslog UI injected successfully!\033[0m") + except Exception as e: + print(f"\033[41mError during injection: {e}\033[0m") + else: + print("Backup exists; assume already injected.") + +def restore_syslog_ui(source, target, env): + print("\033[44m==== inject_syslog_ui.py (POST BUILD) ====\033[0m") + project_dir = env.subst("$PROJECT_DIR") + html_path = os.path.join(project_dir, "wled00/data/settings_sync.htm") + bak = html_path + ".backup" + + # restore only if backup file is present + if os.path.exists(bak): + print("Restoring original file from backup...") + if os.path.exists(html_path): + os.chmod(html_path, 0o644) + shutil.copy2(bak, html_path) + os.remove(bak) + +# always register the post-action on checkprogsize so it runs every build +env.AddPostAction("checkprogsize", restore_syslog_ui) + +# only inject on full build +if is_full_build: + inject_syslog_ui(None, None, env) \ No newline at end of file diff --git a/platformio.ini b/platformio.ini index a7485244cd..8cee7ea9b8 100644 --- a/platformio.ini +++ b/platformio.ini @@ -115,6 +115,7 @@ extra_scripts = post:pio-scripts/strip-floats.py pre:pio-scripts/user_config_copy.py pre:pio-scripts/load_usermods.py + pre:pio-scripts/inject_syslog_ui.py pre:pio-scripts/build_ui.py ; post:pio-scripts/obj-dump.py ;; convenience script to create a disassembly dump of the firmware (hardcore debugging) diff --git a/wled00/data/settings_sync.htm b/wled00/data/settings_sync.htm index e0ec292f05..6745817e8a 100644 --- a/wled00/data/settings_sync.htm +++ b/wled00/data/settings_sync.htm @@ -237,59 +237,7 @@

Serial


Keep at 115200 to use Improv. Some boards may not support high rates. -

Syslog

-
- This firmware build does not support Syslog interface.
-
-
-Enable Syslog:
-Host:
-Port:
-Protocol: -
-Facility: -
-Severity: -
-
+
From cbee84e0be1f319aabdb4668cb444fb02bcb5b08 Mon Sep 17 00:00:00 2001 From: KrX3D Date: Sun, 27 Apr 2025 00:15:32 +0200 Subject: [PATCH 05/19] coderabbitai improvements --- pio-scripts/inject_syslog_ui.py | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/pio-scripts/inject_syslog_ui.py b/pio-scripts/inject_syslog_ui.py index 03c208c5f8..fc3fac6342 100644 --- a/pio-scripts/inject_syslog_ui.py +++ b/pio-scripts/inject_syslog_ui.py @@ -1,5 +1,5 @@ # pio-scripts/inject_syslog_ui.py -import os, shutil, sys +import os, shutil from SCons.Script import Import Import("env") @@ -117,7 +117,8 @@ def inject_syslog_ui(source, target, env): print("Backing up and injecting Syslog UI...") shutil.copyfile(html_path, bak) try: - original = open(html_path, 'r', encoding='utf8').read() + with open(html_path, 'r', encoding='utf8') as f: + original = f.read() modified = original # replace existing section if present @@ -146,8 +147,20 @@ def inject_syslog_ui(source, target, env): print("\033[42mSyslog UI injected successfully!\033[0m") except Exception as e: print(f"\033[41mError during injection: {e}\033[0m") + # injection failed → remove backup so we’ll retry next time + if os.path.exists(bak): + os.remove(bak) else: print("Backup exists; assume already injected.") + # verify that SYSLOG markers really are in the file + with open(html_path, 'r', encoding='utf8') as f: + content = f.read() + if '' not in content or '' not in content: + print("Backup exists but SYSLOG markers missing—forcing re-injection.") + os.remove(bak) + inject_syslog_ui(source, target, env) + else: + print("Backup exists and markers found; already injected.") def restore_syslog_ui(source, target, env): print("\033[44m==== inject_syslog_ui.py (POST BUILD) ====\033[0m") From 4c9b735e47d13d72dcf7a12ebc6a4ef9bbace00e Mon Sep 17 00:00:00 2001 From: KrX3D Date: Sun, 27 Apr 2025 00:19:31 +0200 Subject: [PATCH 06/19] hide feature was removed since it no longer needed --- pio-scripts/inject_syslog_ui.py | 3 --- wled00/xml.cpp | 2 -- 2 files changed, 5 deletions(-) diff --git a/pio-scripts/inject_syslog_ui.py b/pio-scripts/inject_syslog_ui.py index fc3fac6342..0725cf3cf9 100644 --- a/pio-scripts/inject_syslog_ui.py +++ b/pio-scripts/inject_syslog_ui.py @@ -23,9 +23,6 @@ def set_syslog_state(project_dir, enabled): # This is the HTML we want to inject SYSLOG_HTML = """

Syslog

-
- This firmware build does not support Syslog interface.
-
Enable Syslog:
Host:
diff --git a/wled00/xml.cpp b/wled00/xml.cpp index ff1b5f0daf..b1606be217 100644 --- a/wled00/xml.cpp +++ b/wled00/xml.cpp @@ -524,8 +524,6 @@ void getSettingsJS(byte subPage, Print& settingsScript) printSetFormValue (settingsScript,PSTR("SL_proto"), syslogProtocol); // protocol printSetFormValue (settingsScript,PSTR("SL_fac"), syslogFacility); // facility printSetFormValue (settingsScript,PSTR("SL_sev"), syslogSeverity); // severity - #else - settingsScript.print(F("toggle('Syslog');")); // hide Syslog Sync settings #endif #ifndef WLED_ENABLE_ADALIGHT From 3007dcf4a1b405d13662a197987502daf205ec1f Mon Sep 17 00:00:00 2001 From: KrX3D Date: Sun, 27 Apr 2025 00:27:19 +0200 Subject: [PATCH 07/19] more coderabbitai improvements --- pio-scripts/inject_syslog_ui.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pio-scripts/inject_syslog_ui.py b/pio-scripts/inject_syslog_ui.py index 0725cf3cf9..47c3b36383 100644 --- a/pio-scripts/inject_syslog_ui.py +++ b/pio-scripts/inject_syslog_ui.py @@ -74,7 +74,7 @@ def set_syslog_state(project_dir, enabled):
""" -def inject_syslog_ui(source, target, env): +def inject_syslog_ui(source, target, env, retry_count=0): print("\033[44m==== inject_syslog_ui.py (PRE BUILD) ====\033[0m") if not is_full_build: print("\033[43mNot a full build, skipping Syslog UI operations.\033[0m") @@ -155,7 +155,11 @@ def inject_syslog_ui(source, target, env): if '' not in content or '' not in content: print("Backup exists but SYSLOG markers missing—forcing re-injection.") os.remove(bak) - inject_syslog_ui(source, target, env) + # only retry up to 3 times + if retry_count < 3: + inject_syslog_ui(source, target, env, retry_count + 1) + else: + print("\033[41mToo many retry attempts. Manual intervention required.\033[0m") else: print("Backup exists and markers found; already injected.") From 14910fcc6ccf61e0db7015c8f0a042132ff6e00f Mon Sep 17 00:00:00 2001 From: KrX3D Date: Sun, 27 Apr 2025 00:34:38 +0200 Subject: [PATCH 08/19] more coderabbitai improvements --- pio-scripts/inject_syslog_ui.py | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pio-scripts/inject_syslog_ui.py b/pio-scripts/inject_syslog_ui.py index 47c3b36383..0bf5161a40 100644 --- a/pio-scripts/inject_syslog_ui.py +++ b/pio-scripts/inject_syslog_ui.py @@ -1,4 +1,14 @@ # pio-scripts/inject_syslog_ui.py + +""" +PlatformIO build script to conditionally inject Syslog UI elements into the settings HTML file. + +This script: +1. Injects Syslog UI elements when WLED_ENABLE_SYSLOG is defined in build flags +2. Restores the original HTML file after build completion +3. Tracks state between builds to force UI rebuilds when necessary +""" + import os, shutil from SCons.Script import Import @@ -157,6 +167,9 @@ def inject_syslog_ui(source, target, env, retry_count=0): os.remove(bak) # only retry up to 3 times if retry_count < 3: + # Add a small delay before retrying + import time + time.sleep(0.5 * (retry_count + 1)) # Increasing delay with each retry inject_syslog_ui(source, target, env, retry_count + 1) else: print("\033[41mToo many retry attempts. Manual intervention required.\033[0m") From 0f50d2823304aec713b0fd3ce4e27c51f9e70721 Mon Sep 17 00:00:00 2001 From: KrX3D Date: Sun, 27 Apr 2025 00:50:47 +0200 Subject: [PATCH 09/19] more coderabbitai improvements --- pio-scripts/inject_syslog_ui.py | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/pio-scripts/inject_syslog_ui.py b/pio-scripts/inject_syslog_ui.py index 0bf5161a40..5510a91623 100644 --- a/pio-scripts/inject_syslog_ui.py +++ b/pio-scripts/inject_syslog_ui.py @@ -9,7 +9,7 @@ 3. Tracks state between builds to force UI rebuilds when necessary """ -import os, shutil +import os, re, shutil from SCons.Script import Import Import("env") @@ -94,7 +94,7 @@ def inject_syslog_ui(source, target, env, retry_count=0): build_flags = env.get("BUILD_FLAGS", "") if isinstance(build_flags, list): build_flags = " ".join(build_flags) - has_syslog = ("-D WLED_ENABLE_SYSLOG" in build_flags or "-DWLED_ENABLE_SYSLOG" in build_flags) + has_syslog = bool(re.search(r'-D\s*WLED_ENABLE_SYSLOG', build_flags)) project_dir = env.subst("$PROJECT_DIR") html_path = os.path.join(project_dir, "wled00/data/settings_sync.htm") @@ -152,8 +152,14 @@ def inject_syslog_ui(source, target, env, retry_count=0): with open(html_path, 'w', encoding='utf8') as f: f.write(modified) print("\033[42mSyslog UI injected successfully!\033[0m") + + except (IOError, OSError) as e: + print(f"\033[41mFile operation error during injection: {e}\033[0m") + # injection failed → remove backup so we'll retry next time + if os.path.exists(bak): + os.remove(bak) except Exception as e: - print(f"\033[41mError during injection: {e}\033[0m") + print(f"\033[41mUnexpected error during injection: {e}\033[0m") # injection failed → remove backup so we’ll retry next time if os.path.exists(bak): os.remove(bak) From f72815d75aa15bef677f45d35145f5f768e12483 Mon Sep 17 00:00:00 2001 From: KrX3D Date: Mon, 5 May 2025 15:29:35 +0200 Subject: [PATCH 10/19] removed configuration options that do not add value --- pio-scripts/inject_syslog_ui.py | 12 ------------ wled00/json.cpp | 1 + wled00/syslog.cpp | 32 ++++++++++++++++++++------------ wled00/syslog.h | 14 +------------- wled00/wled.h | 2 +- 5 files changed, 23 insertions(+), 38 deletions(-) diff --git a/pio-scripts/inject_syslog_ui.py b/pio-scripts/inject_syslog_ui.py index 5510a91623..fba49536b4 100644 --- a/pio-scripts/inject_syslog_ui.py +++ b/pio-scripts/inject_syslog_ui.py @@ -47,20 +47,8 @@ def set_syslog_state(project_dir, enabled):
+ + """ From dada672a6b77e8c9d52287c4f444c21c8dc3afb6 Mon Sep 17 00:00:00 2001 From: KrX3D Date: Thu, 15 May 2025 23:31:30 +0200 Subject: [PATCH 13/19] - Fix ompiling porblem with esp32_dev board - removing #015 and only whitespace line from beeing sent - replace space with _ from serverDescription --- wled00/syslog.cpp | 66 +++++++++++++++++++++++++++++++++++++---------- 1 file changed, 52 insertions(+), 14 deletions(-) diff --git a/wled00/syslog.cpp b/wled00/syslog.cpp index 21a4d08fe9..e296729f12 100644 --- a/wled00/syslog.cpp +++ b/wled00/syslog.cpp @@ -28,13 +28,13 @@ static const char* severityNames[] = { }; SyslogPrinter::SyslogPrinter() : + _lastOperationSucceeded(true), + _lastErrorMessage(""), _facility(SYSLOG_LOCAL0), _severity(SYSLOG_DEBUG), _protocol(SYSLOG_PROTO_BSD), _appName("WLED"), - _bufferIndex(0), - _lastOperationSucceeded(true), - _lastErrorMessage("") {} + _bufferIndex(0) {} void SyslogPrinter::begin(const char* host, uint16_t port, uint8_t facility, uint8_t severity, uint8_t protocol) { @@ -95,16 +95,32 @@ bool SyslogPrinter::resolveHostname() { void SyslogPrinter::flushBuffer() { if (_bufferIndex == 0) return; - - // Trim any trailing CR so syslog server won’t show “#015” - if (_bufferIndex > 0 && _buffer[_bufferIndex-1] == '\r') _bufferIndex--; - + + // Skip pure "#015" lines + if (_bufferIndex == 4 && memcmp(_buffer, "#015", 4) == 0) { + _bufferIndex = 0; + return; + } + + // Check if the message contains only whitespace + bool onlyWhitespace = true; + for (size_t i = 0; i < _bufferIndex; i++) { + if (_buffer[i] != ' ' && _buffer[i] != '\t') { + onlyWhitespace = false; + break; + } + } + if (onlyWhitespace) { + _bufferIndex = 0; + return; + } + // Null-terminate _buffer[_bufferIndex] = '\0'; - + // Send the buffer with default severity write((const uint8_t*)_buffer, _bufferIndex, _severity); - + // Reset buffer index _bufferIndex = 0; } @@ -115,7 +131,7 @@ size_t SyslogPrinter::write(uint8_t c) { _buffer[_bufferIndex++] = c; } - // If newline or buffer full, flush + // If newline or buffer full, flush buffer if (c == '\n' || _bufferIndex >= sizeof(_buffer) - 1) { flushBuffer(); } @@ -149,12 +165,34 @@ size_t SyslogPrinter::write(const uint8_t *buf, size_t size, uint8_t severity) { _lastErrorMessage = F("Failed to resolve hostname"); return 0; } - + + // Check for special case - literal "#015" string + if (size >= 4 && buf[0] == '#' && buf[1] == '0' && buf[2] == '1' && buf[3] == '5') { + return size; // Skip sending this message + } + + // Skip empty messages + if (size == 0) return 0; + + // Check if the message contains only whitespace + bool onlyWhitespace = true; + for (size_t i = 0; i < size; i++) { + if (buf[i] != ' ' && buf[i] != '\t' && buf[i] != '\r' && buf[i] != '\n') { + onlyWhitespace = false; + break; + } + } + if (onlyWhitespace) return size; // Skip sending this message + syslogUdp.beginPacket(syslogHostIP, syslogPort); // Calculate priority value uint8_t pri = (_facility << 3) | severity; - + + // Add hostname (replacing spaces with underscores) and app name + String cleanHostname = String(serverDescription); + cleanHostname.replace(' ', '_'); + // Handle different syslog protocol formats switch (_protocol) { case SYSLOG_PROTO_BSD: @@ -178,7 +216,7 @@ size_t SyslogPrinter::write(const uint8_t *buf, size_t size, uint8_t severity) { } // Add hostname and app name - syslogUdp.print(serverDescription); + syslogUdp.print(cleanHostname); syslogUdp.print(" "); syslogUdp.print(_appName); syslogUdp.print(": "); @@ -205,7 +243,7 @@ size_t SyslogPrinter::write(const uint8_t *buf, size_t size, uint8_t severity) { } // Add hostname, app name, and other fields (using - for empty fields) - syslogUdp.print(serverDescription); + syslogUdp.print(cleanHostname); syslogUdp.print(" "); syslogUdp.print(_appName); syslogUdp.print(" - - - "); // PROCID, MSGID, and STRUCTURED-DATA are empty From 056ac1c8300746fa0f6d723eae9794c874c0461f Mon Sep 17 00:00:00 2001 From: KrX3D Date: Fri, 16 May 2025 18:33:25 +0200 Subject: [PATCH 14/19] moved strings to flash - suggestion by DjordjeMandic --- wled00/syslog.cpp | 98 +++++++++++++++++++++++++---------------------- wled00/syslog.h | 15 ++++---- 2 files changed, 61 insertions(+), 52 deletions(-) diff --git a/wled00/syslog.cpp b/wled00/syslog.cpp index e296729f12..fbe0ac00f0 100644 --- a/wled00/syslog.cpp +++ b/wled00/syslog.cpp @@ -3,29 +3,31 @@ #include "syslog.h" -static const __FlashStringHelper* protoNames[] = { F("BSD"), F("RFC5424"), F("RAW") }; - -const char* getFacilityName(uint8_t code) { - switch (code) { - case 0: return "KERN"; - case 1: return "USER"; - case 3: return "DAEMON"; - case 5: return "SYSLOG"; - case 16: return "LCL0"; - case 17: return "LCL1"; - case 18: return "LCL2"; - case 19: return "LCL3"; - case 20: return "LCL4"; - case 21: return "LCL5"; - case 22: return "LCL6"; - case 23: return "LCL7"; - default: return "UNKNOWN"; - } -} +static const char* const protoNames[] PROGMEM = { + PSTR("BSD"), + PSTR("RFC5424"), + PSTR("RAW"), + PSTR("UNKNOWN") +}; +static const uint8_t protoCount = sizeof(protoNames)/sizeof(*protoNames); -static const char* severityNames[] = { - "EMERG","ALERT","CRIT","ERR","WARNING","NOTICE","INFO","DEBUG" +static const char* const facilityNames[] PROGMEM = { + PSTR("KERN"), PSTR("USER"), PSTR("UNKNOWN"), PSTR("DAEMON"), + PSTR("UNKNOWN"),PSTR("SYSLOG"), PSTR("UNKNOWN"), PSTR("UNKNOWN"), + PSTR("UNKNOWN"),PSTR("UNKNOWN"),PSTR("UNKNOWN"), PSTR("UNKNOWN"), + PSTR("UNKNOWN"),PSTR("UNKNOWN"),PSTR("UNKNOWN"), PSTR("UNKNOWN"), + PSTR("LCL0"), PSTR("LCL1"), PSTR("LCL2"), PSTR("LCL3"), + PSTR("LCL4"), PSTR("LCL5"), PSTR("LCL6"), PSTR("LCL7"), + PSTR("UNKNOWN") // catch-all at index 24 }; +static const uint8_t facCount = sizeof(facilityNames)/sizeof(*facilityNames); + +static const char* const severityNames[] PROGMEM = { + PSTR("EMERG"), PSTR("ALERT"), PSTR("CRIT"), PSTR("ERR"), + PSTR("WARN"), PSTR("NOTE"), PSTR("INFO"), PSTR("DEBUG"), + PSTR("UNKNOWN") +}; +static const uint8_t sevCount = sizeof(severityNames) / sizeof(*severityNames); SyslogPrinter::SyslogPrinter() : _lastOperationSucceeded(true), @@ -40,29 +42,33 @@ void SyslogPrinter::begin(const char* host, uint16_t port, uint8_t facility, uint8_t severity, uint8_t protocol) { DEBUG_PRINTF_P(PSTR("===== WLED SYSLOG CONFIGURATION =====\n")); - DEBUG_PRINTF_P(PSTR(" Hostname: %s\n"), syslogHost); - DEBUG_PRINTF_P(PSTR(" Cached IP: %s\n"), syslogHostIP.toString().c_str()); - DEBUG_PRINTF_P(PSTR(" Port: %u\n"), (unsigned)syslogPort); - DEBUG_PRINTF_P(PSTR(" Protocol: %u (%s)\n"), - protocol, - protocol <= 2 ? (const char*)protoNames[protocol] : "UNKNOWN" - ); - DEBUG_PRINTF_P(PSTR(" Facility: %u (%s)\n"), - (unsigned)facility, - getFacilityName(facility)); - DEBUG_PRINTF_P(PSTR(" Severity: %u (%s)\n"), - (unsigned)severity, - (severity < sizeof(severityNames)/sizeof(severityNames[0])) - ? severityNames[severity] - : PSTR("UNKNOWN")); + DEBUG_PRINTF_P(PSTR(" Hostname: %s\n"), host); + DEBUG_PRINTF_P(PSTR(" Cached IP: %s\n"), syslogHostIP.toString().c_str()); + DEBUG_PRINTF_P(PSTR(" Port: %u\n"), (unsigned)port); + + // Protocol + uint8_t pidx = protocol < (protoCount - 1) ? protocol : (protoCount - 1); + const char* pstr = (const char*)pgm_read_ptr(&protoNames[pidx]); + DEBUG_PRINTF_P(PSTR(" Protocol: %u (%s)\n"), (unsigned)protocol, pstr); + + // — Facility + uint8_t fidx = facility < (facCount - 1) ? facility : (facCount - 1); + const char* fstr = (const char*)pgm_read_ptr(&facilityNames[fidx]); + DEBUG_PRINTF_P(PSTR(" Facility: %u (%s)\n"), (unsigned)facility, fstr); + + // Severity + uint8_t idx = severity < sevCount-1 ? severity : sevCount-1; + const char* sevStr = (const char*)pgm_read_ptr(&severityNames[idx]); + DEBUG_PRINTF_P(PSTR(" Severity: %u (%s)\n"), (unsigned)severity, sevStr); + DEBUG_PRINTF_P(PSTR("======================================\n")); - + strlcpy(syslogHost, host, sizeof(syslogHost)); syslogPort = port; _facility = facility; _severity = severity; _protocol = protocol; - + // clear any cached IP so resolveHostname() will run next write() syslogHostIP = IPAddress(0,0,0,0); } @@ -195,15 +201,17 @@ size_t SyslogPrinter::write(const uint8_t *buf, size_t size, uint8_t severity) { // Handle different syslog protocol formats switch (_protocol) { - case SYSLOG_PROTO_BSD: + case SYSLOG_PROTO_BSD: // RFC 3164 format: TIMESTAMP HOSTNAME APP-NAME: MESSAGE syslogUdp.printf("<%d>", pri); if (ntpEnabled && ntpConnected) { // Month abbreviation - const char* months[] = {"Jan", "Feb", "Mar", "Apr", "May", "Jun", - "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"}; - + static const char* const months[] = { + "Jan","Feb","Mar","Apr","May","Jun", + "Jul","Aug","Sep","Oct","Nov","Dec" + }; + syslogUdp.printf("%s %2d %02d:%02d:%02d ", months[month(localTime) - 1], day(localTime), @@ -212,7 +220,7 @@ size_t SyslogPrinter::write(const uint8_t *buf, size_t size, uint8_t severity) { second(localTime)); } else { // No valid time available - syslogUdp.print("Jan 01 00:00:00 "); + syslogUdp.print(F("Jan 01 00:00:00 ")); } // Add hostname and app name @@ -239,14 +247,14 @@ size_t SyslogPrinter::write(const uint8_t *buf, size_t size, uint8_t severity) { second(localTime)); } else { // No valid time available - syslogUdp.print("1970-01-01T00:00:00Z "); + syslogUdp.print(F("1970-01-01T00:00:00Z ")); } // Add hostname, app name, and other fields (using - for empty fields) syslogUdp.print(cleanHostname); syslogUdp.print(" "); syslogUdp.print(_appName); - syslogUdp.print(" - - - "); // PROCID, MSGID, and STRUCTURED-DATA are empty + syslogUdp.print(F(" - - - ")); // PROCID, MSGID, and STRUCTURED-DATA are empty // Add message content size = syslogUdp.write(buf, size); diff --git a/wled00/syslog.h b/wled00/syslog.h index 3138d707b3..4131b20773 100644 --- a/wled00/syslog.h +++ b/wled00/syslog.h @@ -3,6 +3,11 @@ #include #include +// Buffer management +#ifndef SYSLOG_BUFFER_SIZE + #define SYSLOG_BUFFER_SIZE 128 +#endif + // Syslog facility codes #define SYSLOG_KERN 0 // kernel messages #define SYSLOG_USER 1 // user-level messages @@ -46,15 +51,11 @@ class SyslogPrinter : public Print { uint8_t _protocol; String _appName; - // Buffer management - #ifndef SYSLOG_BUFFER_SIZE - #define SYSLOG_BUFFER_SIZE 128 - #endif char _buffer[SYSLOG_BUFFER_SIZE]; // Buffer for collecting characters size_t _bufferIndex; void flushBuffer(); - + public: SyslogPrinter(); void begin(const char* host, uint16_t port, @@ -62,11 +63,11 @@ class SyslogPrinter : public Print { uint8_t severity = SYSLOG_DEBUG, uint8_t protocol = SYSLOG_PROTO_BSD); void setAppName(const String &appName); - + // Print interface implementation virtual size_t write(uint8_t c); virtual size_t write(const uint8_t *buf, size_t size); - + // Severity override for specific messages size_t write(const uint8_t *buf, size_t size, uint8_t severity); From 11f5dd2f83521e0bea3bccdc974b1880104704c5 Mon Sep 17 00:00:00 2001 From: KrX3D Date: Fri, 16 May 2025 19:11:52 +0200 Subject: [PATCH 15/19] removed (commented out) not used features - request netmindz --- pio-scripts/inject_syslog_ui.py | 4 ++-- wled00/cfg.cpp | 12 ++++++------ wled00/set.cpp | 12 ++++++------ wled00/syslog.cpp | 18 ++++++++++++++++-- wled00/syslog.h | 24 ++++++++++++++++-------- wled00/wled.h | 15 +++++++++++++++ wled00/xml.cpp | 6 +++--- 7 files changed, 64 insertions(+), 27 deletions(-) diff --git a/pio-scripts/inject_syslog_ui.py b/pio-scripts/inject_syslog_ui.py index f476f0f94a..9a8f0af5f6 100644 --- a/pio-scripts/inject_syslog_ui.py +++ b/pio-scripts/inject_syslog_ui.py @@ -37,14 +37,14 @@ def set_syslog_state(project_dir, enabled): Enable Syslog:
Host:
Port:
+ + - """ @@ -120,15 +84,9 @@ def inject_syslog_ui(source, target, env, retry_count=0): original = f.read() modified = original - # replace existing section if present - if '' in modified and '' in modified: - start = modified.index('') - end = modified.index('') + len('') - modified = ( - modified[:start] - + '\n' + SYSLOG_HTML + '\n' - + modified[end:] - ) + # replace the single comment with HTML + if '' in modified: + modified = modified.replace('', SYSLOG_HTML) else: # insert before last
idx = modified.rfind('
') @@ -137,7 +95,7 @@ def inject_syslog_ui(source, target, env, retry_count=0): return modified = ( modified[:idx] - + '\n' + SYSLOG_HTML + '\n\n' + + SYSLOG_HTML + '\n' + modified[idx:] ) @@ -160,7 +118,7 @@ def inject_syslog_ui(source, target, env, retry_count=0): # verify that SYSLOG markers really are in the file with open(html_path, 'r', encoding='utf8') as f: content = f.read() - if '' not in content or '' not in content: + if '' not in content: print("Backup exists but SYSLOG markers missing—forcing re-injection.") os.remove(bak) # only retry up to 3 times diff --git a/wled00/cfg.cpp b/wled00/cfg.cpp index f400ea2e6a..5e06944920 100644 --- a/wled00/cfg.cpp +++ b/wled00/cfg.cpp @@ -541,9 +541,6 @@ bool deserializeConfig(JsonObject doc, bool fromFS) { CJSON(syslogEnabled, if_syslog["en"]); getStringFromJson(syslogHost, if_syslog[F("host")], 33); CJSON(syslogPort, if_syslog["port"]); - // CJSON(syslogProtocol, if_syslog["proto"]); - // CJSON(syslogFacility, if_syslog["fac"]); - // CJSON(syslogSeverity, if_syslog["sev"]); #endif JsonObject if_ntp = interfaces[F("ntp")]; @@ -1066,9 +1063,6 @@ void serializeConfig(JsonObject root) { if_syslog["en"] = syslogEnabled; if_syslog["host"] = syslogHost; if_syslog["port"] = syslogPort; - // if_syslog["proto"] = syslogProtocol; - // if_syslog["fac"] = syslogFacility; - // if_syslog["sev"] = syslogSeverity; #endif JsonObject if_ntp = interfaces.createNestedObject("ntp"); diff --git a/wled00/data/settings_sync.htm b/wled00/data/settings_sync.htm index 6745817e8a..983d0a6cbc 100644 --- a/wled00/data/settings_sync.htm +++ b/wled00/data/settings_sync.htm @@ -237,7 +237,7 @@

Serial


Keep at 115200 to use Improv. Some boards may not support high rates. - +
diff --git a/wled00/set.cpp b/wled00/set.cpp index da159b5174..1db411af47 100644 --- a/wled00/set.cpp +++ b/wled00/set.cpp @@ -479,16 +479,7 @@ void handleSettingsSet(AsyncWebServerRequest *request, byte subPage) t = request->arg(F("SL_port")).toInt(); if (t > 0) syslogPort = t; - - // t = request->arg(F("SL_proto")).toInt(); - // if (t >= SYSLOG_PROTO_BSD && t <= SYSLOG_PROTO_RAW) syslogProtocol = t; - - // t = request->arg(F("SL_fac")).toInt(); - // if (t >= SYSLOG_KERN && t <= SYSLOG_LOCAL7) syslogFacility = t; - - // t = request->arg(F("SL_sev")).toInt(); - // if (t >= SYSLOG_EMERG && t <= SYSLOG_DEBUG) syslogSeverity = t; - + Syslog.begin(syslogHost, syslogPort, syslogFacility, syslogSeverity, syslogProtocol); diff --git a/wled00/syslog.cpp b/wled00/syslog.cpp index 9ee59c318e..384a937e4e 100644 --- a/wled00/syslog.cpp +++ b/wled00/syslog.cpp @@ -3,42 +3,6 @@ #include "syslog.h" -// Comment out but preserve the protocol names -/* -static const char* const protoNames[] PROGMEM = { - PSTR("BSD"), - PSTR("RFC5424"), - PSTR("RAW"), - PSTR("UNKNOWN") -}; -static const uint8_t protoCount = sizeof(protoNames)/sizeof(*protoNames); -*/ - -// Comment out but preserve facility names -/* -// We fill invalid entries with PSTR("UNKNOWN") so we can index 0..24 safely -static const char* const facilityNames[] PROGMEM = { - PSTR("KERN"), PSTR("USER"), PSTR("UNKNOWN"), PSTR("DAEMON"), - PSTR("UNKNOWN"),PSTR("SYSLOG"), PSTR("UNKNOWN"), PSTR("UNKNOWN"), - PSTR("UNKNOWN"),PSTR("UNKNOWN"),PSTR("UNKNOWN"), PSTR("UNKNOWN"), - PSTR("UNKNOWN"),PSTR("UNKNOWN"),PSTR("UNKNOWN"), PSTR("UNKNOWN"), - PSTR("LCL0"), PSTR("LCL1"), PSTR("LCL2"), PSTR("LCL3"), - PSTR("LCL4"), PSTR("LCL5"), PSTR("LCL6"), PSTR("LCL7"), - PSTR("UNKNOWN") // catch-all at index 24 -}; -static const uint8_t facCount = sizeof(facilityNames)/sizeof(*facilityNames); -*/ - -// Comment out but preserve severity names -/* -static const char* const severityNames[] PROGMEM = { - PSTR("EMERG"), PSTR("ALERT"), PSTR("CRIT"), PSTR("ERR"), - PSTR("WARN"), PSTR("NOTE"), PSTR("INFO"), PSTR("DEBUG"), - PSTR("UNKNOWN") -}; -static const uint8_t sevCount = sizeof(severityNames) / sizeof(*severityNames); -*/ - SyslogPrinter::SyslogPrinter() : _lastOperationSucceeded(true), _lastErrorMessage(""), @@ -55,24 +19,6 @@ void SyslogPrinter::begin(const char* host, uint16_t port, DEBUG_PRINTF_P(PSTR(" Hostname: %s\n"), host); DEBUG_PRINTF_P(PSTR(" Cached IP: %s\n"), syslogHostIP.toString().c_str()); DEBUG_PRINTF_P(PSTR(" Port: %u\n"), (unsigned)port); - - /* - // Protocol - uint8_t pidx = protocol < (protoCount - 1) ? protocol : (protoCount - 1); - const char* pstr = (const char*)pgm_read_ptr(&protoNames[pidx]); - DEBUG_PRINTF_P(PSTR(" Protocol: %u (%s)\n"), (unsigned)protocol, pstr); - - // — Facility - uint8_t fidx = facility < (facCount - 1) ? facility : (facCount - 1); - const char* fstr = (const char*)pgm_read_ptr(&facilityNames[fidx]); - DEBUG_PRINTF_P(PSTR(" Facility: %u (%s)\n"), (unsigned)facility, fstr); - - // Severity - uint8_t idx = severity < sevCount-1 ? severity : sevCount-1; - const char* sevStr = (const char*)pgm_read_ptr(&severityNames[idx]); - DEBUG_PRINTF_P(PSTR(" Severity: %u (%s)\n"), (unsigned)severity, sevStr); - */ - DEBUG_PRINTF_P(PSTR("======================================\n")); strlcpy(syslogHost, host, sizeof(syslogHost)); @@ -211,76 +157,35 @@ size_t SyslogPrinter::write(const uint8_t *buf, size_t size, uint8_t severity) { String cleanHostname = String(serverDescription); cleanHostname.replace(' ', '_'); - // Handle different syslog protocol formats - // Note: Only BSD protocol is currently implemented; RFC5424 and RAW are preserved for future use - // switch (_protocol) { - // case SYSLOG_PROTO_BSD: - // RFC 3164 format: TIMESTAMP HOSTNAME APP-NAME: MESSAGE - syslogUdp.printf("<%d>", pri); - - if (ntpEnabled && ntpConnected) { - // Month abbreviation - static const char* const months[] = { - "Jan","Feb","Mar","Apr","May","Jun", - "Jul","Aug","Sep","Oct","Nov","Dec" - }; - - syslogUdp.printf("%s %2d %02d:%02d:%02d ", - months[month(localTime) - 1], - day(localTime), - hour(localTime), - minute(localTime), - second(localTime)); - } else { - // No valid time available - syslogUdp.print(F("Jan 01 00:00:00 ")); - } - - // Add hostname and app name - syslogUdp.print(cleanHostname); - syslogUdp.print(" "); - syslogUdp.print(_appName); - syslogUdp.print(": "); - - // Add message content - size = syslogUdp.write(buf, size); - /* - break; - - case SYSLOG_PROTO_RFC5424: - // RFC 5424 format: VERSION TIMESTAMP HOSTNAME APP-NAME PROCID MSGID STRUCTURED-DATA MSG - syslogUdp.printf("<%d>1 ", pri); // Version is always 1 - - if (ntpEnabled && ntpConnected) { - syslogUdp.printf("%04d-%02d-%02dT%02d:%02d:%02dZ ", - year(localTime), - month(localTime), - day(localTime), - hour(localTime), - minute(localTime), - second(localTime)); - } else { - // No valid time available - syslogUdp.print(F("1970-01-01T00:00:00Z ")); - } - - // Add hostname, app name, and other fields (using - for empty fields) - syslogUdp.print(cleanHostname); - syslogUdp.print(" "); - syslogUdp.print(_appName); - syslogUdp.print(F(" - - - ")); // PROCID, MSGID, and STRUCTURED-DATA are empty - - // Add message content - size = syslogUdp.write(buf, size); - break; - - case SYSLOG_PROTO_RAW: - default: - // Just send the raw message (like original NetDebug) - size = syslogUdp.write(buf, size); - break; + // Note: Only BSD protocol is currently implemented + syslogUdp.printf("<%d>", pri); + + if (ntpEnabled && ntpConnected) { + // Month abbreviation + static const char* const months[] = { + "Jan","Feb","Mar","Apr","May","Jun", + "Jul","Aug","Sep","Oct","Nov","Dec" + }; + + syslogUdp.printf("%s %2d %02d:%02d:%02d ", + months[month(localTime) - 1], + day(localTime), + hour(localTime), + minute(localTime), + second(localTime)); + } else { + // No valid time available + syslogUdp.print(F("Jan 01 00:00:00 ")); } - */ + + // Add hostname and app name + syslogUdp.print(cleanHostname); + syslogUdp.print(" "); + syslogUdp.print(_appName); + syslogUdp.print(": "); + + // Add message content + size = syslogUdp.write(buf, size); syslogUdp.endPacket(); return size; diff --git a/wled00/syslog.h b/wled00/syslog.h index 46c220347a..98b4e39134 100644 --- a/wled00/syslog.h +++ b/wled00/syslog.h @@ -8,42 +8,11 @@ #define SYSLOG_BUFFER_SIZE 128 #endif -// Syslog facility codes - commented out but preserved -/* -#define SYSLOG_KERN 0 // kernel messages -#define SYSLOG_USER 1 // user-level messages -#define SYSLOG_DAEMON 3 // system daemons -#define SYSLOG_SYSLOG 5 // messages generated internally by syslogd -*/ #define SYSLOG_LOCAL0 16 // local use 0 -/* -#define SYSLOG_LOCAL1 17 // local use 1 -#define SYSLOG_LOCAL2 18 // local use 2 -#define SYSLOG_LOCAL3 19 // local use 3 -#define SYSLOG_LOCAL4 20 // local use 4 -#define SYSLOG_LOCAL5 21 // local use 5 -#define SYSLOG_LOCAL6 22 // local use 6 -#define SYSLOG_LOCAL7 23 // local use 7 -*/ - -// Syslog severity levels - commented out but preserved -/* -#define SYSLOG_EMERG 0 // Emergency: system is unusable -#define SYSLOG_ALERT 1 // Alert: action must be taken immediately -#define SYSLOG_CRIT 2 // Critical: critical conditions -#define SYSLOG_ERR 3 // Error: error conditions -#define SYSLOG_WARNING 4 // Warning: warning conditions -#define SYSLOG_NOTICE 5 // Notice: normal but significant condition -#define SYSLOG_INFO 6 // Informational: informational messages -*/ #define SYSLOG_DEBUG 7 // Debug: debug-level messages // Syslog protocol formats - commented out but preserved #define SYSLOG_PROTO_BSD 0 // Legacy BSD format (RFC 3164) -/* -#define SYSLOG_PROTO_RFC5424 1 // Modern syslog format (RFC 5424) -#define SYSLOG_PROTO_RAW 2 // Raw text (like original NetDebug) -*/ class SyslogPrinter : public Print { private: From 238e1c47f408cddf258eaf52bf7193f74e21d1bd Mon Sep 17 00:00:00 2001 From: KrX3D Date: Mon, 7 Jul 2025 15:59:32 +0200 Subject: [PATCH 18/19] syslog inject fix / coderabbit improments --- pio-scripts/inject_syslog_ui.py | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/pio-scripts/inject_syslog_ui.py b/pio-scripts/inject_syslog_ui.py index 7bb8beda4e..08077cf636 100644 --- a/pio-scripts/inject_syslog_ui.py +++ b/pio-scripts/inject_syslog_ui.py @@ -31,14 +31,12 @@ def set_syslog_state(project_dir, enabled): f.write("1" if enabled else "0") # This is the HTML we want to inject -SYSLOG_HTML = """ -

Syslog

+SYSLOG_HTML = """

Syslog

Enable Syslog:
Host:
Port:
-
-""" +""" def inject_syslog_ui(source, target, env, retry_count=0): print("\033[44m==== inject_syslog_ui.py (PRE BUILD) ====\033[0m") @@ -50,7 +48,7 @@ def inject_syslog_ui(source, target, env, retry_count=0): build_flags = env.get("BUILD_FLAGS", "") if isinstance(build_flags, list): build_flags = " ".join(build_flags) - has_syslog = bool(re.search(r'-D\s*WLED_ENABLE_SYSLOG', build_flags)) + has_syslog = bool(re.search(r'-D\s*WLED_ENABLE_SYSLOG\b', build_flags)) project_dir = env.subst("$PROJECT_DIR") html_path = os.path.join(project_dir, "wled00/data/settings_sync.htm") @@ -92,6 +90,9 @@ def inject_syslog_ui(source, target, env, retry_count=0): idx = modified.rfind('
') if idx == -1: print("\033[41mCould not find
to insert Syslog UI!\033[0m") + # Clean up backup since injection failed + if os.path.exists(bak): + os.remove(bak) return modified = ( modified[:idx] @@ -118,7 +119,7 @@ def inject_syslog_ui(source, target, env, retry_count=0): # verify that SYSLOG markers really are in the file with open(html_path, 'r', encoding='utf8') as f: content = f.read() - if '' not in content: + if '

Syslog

' not in content: print("Backup exists but SYSLOG markers missing—forcing re-injection.") os.remove(bak) # only retry up to 3 times @@ -141,8 +142,6 @@ def restore_syslog_ui(source, target, env): # restore only if backup file is present if os.path.exists(bak): print("Restoring original file from backup...") - if os.path.exists(html_path): - os.chmod(html_path, 0o644) shutil.copy2(bak, html_path) os.remove(bak) From 77c8f6d492bc19acc9adadc089723a4ddfa3aa10 Mon Sep 17 00:00:00 2001 From: KrX3D Date: Tue, 8 Jul 2025 22:31:54 +0200 Subject: [PATCH 19/19] removed forgotten commented out code --- wled00/wled.h | 24 ------------------------ wled00/xml.cpp | 3 --- 2 files changed, 27 deletions(-) diff --git a/wled00/wled.h b/wled00/wled.h index da6b9cfcb6..e7a3c7a2fa 100644 --- a/wled00/wled.h +++ b/wled00/wled.h @@ -978,32 +978,8 @@ WLED_GLOBAL volatile uint8_t jsonBufferLock _INIT(0); #define WLED_SYSLOG_PORT 514 #endif WLED_GLOBAL int syslogPort _INIT(WLED_SYSLOG_PORT); - - // Preserved code as comments - protocol setting is now hardcoded - /* - #ifndef WLED_SYSLOG_PROTOCOL - #define WLED_SYSLOG_PROTOCOL SYSLOG_PROTO_BSD - #endif - WLED_GLOBAL uint8_t syslogProtocol _INIT(WLED_SYSLOG_PROTOCOL); - */ WLED_GLOBAL uint8_t syslogProtocol _INIT(SYSLOG_PROTO_BSD); // Direct initialization with hardcoded BSD protocol value - - // Preserved code as comments - facility setting is now hardcoded - /* - #ifndef WLED_SYSLOG_FACILITY - #define WLED_SYSLOG_FACILITY SYSLOG_LOCAL0 - #endif - WLED_GLOBAL uint8_t syslogFacility _INIT(WLED_SYSLOG_FACILITY); - */ WLED_GLOBAL uint8_t syslogFacility _INIT(SYSLOG_LOCAL0); // Direct initialization with hardcoded LOCAL0 facility value - - // Preserved code as comments - severity setting is now hardcoded - /* - #ifndef WLED_SYSLOG_SEVERITY - #define WLED_SYSLOG_SEVERITY SYSLOG_DEBUG - #endif - WLED_GLOBAL uint8_t syslogSeverity _INIT(WLED_SYSLOG_SEVERITY); - */ WLED_GLOBAL uint8_t syslogSeverity _INIT(SYSLOG_DEBUG); // Direct initialization with hardcoded DEBUG severity value #elif defined(WLED_DEBUG_HOST) #include "net_debug.h" diff --git a/wled00/xml.cpp b/wled00/xml.cpp index 0fca1242ec..17303bf240 100644 --- a/wled00/xml.cpp +++ b/wled00/xml.cpp @@ -521,9 +521,6 @@ void getSettingsJS(byte subPage, Print& settingsScript) printSetFormCheckbox(settingsScript,PSTR("SL_en"), syslogEnabled); // enable/disable printSetFormValue (settingsScript,PSTR("SL_host"), syslogHost); // host printSetFormValue (settingsScript,PSTR("SL_port"), syslogPort); // port - // printSetFormValue (settingsScript,PSTR("SL_proto"), syslogProtocol); // protocol - // printSetFormValue (settingsScript,PSTR("SL_fac"), syslogFacility); // facility - // printSetFormValue (settingsScript,PSTR("SL_sev"), syslogSeverity); // severity #endif #ifndef WLED_ENABLE_ADALIGHT