feat: add configurable syslog severity level filter#9772
Conversation
Add rsyslog_level field to NetworkConfig protobuf and wire it to the existing Syslog::logMask() filtering mechanism. Users can now control which log messages are forwarded to the rsyslog server by severity. Changes: - Add LogLevel enum and rsyslog_level field (tag 12) to NetworkConfig in config.proto and generated nanopb files - Add syslogLevelToMask() helper in DebugConfiguration.h to map config values to syslog LOG_UPTO() bitmasks - Apply the configured log mask during syslog initialization in both ethClient.cpp (Ethernet) and WiFiAPClient.cpp (WiFi) Default behavior: UNSET (0) is treated as INFO, filtering out DEBUG messages. This reduces syslog noise for production deployments. Companion protobuf PR: meshtastic/protobufs#870 Made-with: Cursor
| meshtastic_Config_NetworkConfig_AddressMode_STATIC = 1 | ||
| } meshtastic_Config_NetworkConfig_AddressMode; | ||
|
|
||
| /* Syslog log level to control which messages are sent to the rsyslog server. |
There was a problem hiding this comment.
Please revert the change to the 'generated' file. This will casue ugly merge conflicts when the protos re re-generated
- Revert config.pb.h to upstream version; manual edits to generated files cause merge conflicts when protos are regenerated. The proto definition lives in companion PR meshtastic/protobufs#870. - Guard rsyslog_level usage with #ifdef so firmware compiles with or without the proto field, defaulting to INFO when absent. - Make TRACE level an explicit case in syslogLevelToMask() with a comment explaining that syslog has no native TRACE level, so it maps to SYSLOG_DEBUG (the most verbose syslog level). Made-with: Cursor
|
@caveman99 Thanks for the review! Both points addressed in ca5a0e2: 1. Generated file reverted — 2. TRACE level — Made it an explicit case with a comment explaining that syslog has no native TRACE level, so it maps to case 5: // LOG_TRACE — syslog has no TRACE; map to DEBUG (most verbose syslog level)
return LOG_UPTO(SYSLOG_DEBUG);
case 10: // LOG_DEBUG
return LOG_UPTO(SYSLOG_DEBUG);Also merged latest upstream/develop — no conflicts. |
|
The name of the protocol is 'syslog', not 'rsyslog'. It's defined by RFC 3164 and RFC 5424. Rsyslog is just one software implementation of said protocol. |
|
@llamafilm Good point — "syslog" is indeed the protocol name (RFC 3164/5424), and "rsyslog" is just one implementation. However, the existing config field is already named |
Add a dedicated Ikoka RF lab build with USB serial control for continuous LoRa preamble and CW carrier testing. Made-with: Cursor
Let the RF test controller accept any positive MHz value and rely on the SX1268 driver to reject unsupported frequencies. Made-with: Cursor
Summary
LogLevelenum andrsyslog_levelfield (tag 12) toNetworkConfigprotobufSyslog::logMask()filtering mechanism via a newsyslogLevelToMask()helperUNSET(0) is treated asINFO, filtering outDEBUGmessagesMotivation
Currently the firmware forwards all log messages to the configured rsyslog server with no way to filter by severity. This generates significant traffic from DEBUG messages that are rarely needed in production. The
Syslogclass already has a_priMaskfiltering mechanism, but it was never wired to a user-configurable setting.Changes
src/mesh/generated/meshtastic/config.pb.hLogLevelenum,rsyslog_levelfield, tags, FIELDLIST, init macros, size updatessrc/DebugConfiguration.hsyslogLevelToMask()inline helper functionsrc/mesh/eth/ethClient.cpplogMask()during Ethernet syslog initializationsrc/mesh/wifi/WiFiAPClient.cpplogMask()during WiFi syslog initializationCompanion PR
Protobuf definition: meshtastic/protobufs#870
Backwards Compatibility
UNSET= 0) maps toINFOlevel - existing devices will filter out DEBUG after upgradersyslog_levelget sensible default behaviorTest plan
rak4631_eth_gwrsyslog_leveltoLOG_DEBUGand verify all messages appearrsyslog_leveltoLOG_WARNINGand verify only WARNING/ERROR/CRITICAL appear