Skip to content

feat: add configurable syslog severity level filter#9772

Open
PhilipLykov wants to merge 11 commits into
meshtastic:developfrom
PhilipLykov:feature/syslog-level-filter
Open

feat: add configurable syslog severity level filter#9772
PhilipLykov wants to merge 11 commits into
meshtastic:developfrom
PhilipLykov:feature/syslog-level-filter

Conversation

@PhilipLykov

@PhilipLykov PhilipLykov commented Feb 27, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add configurable syslog severity level filter to reduce syslog noise
  • Add LogLevel enum and rsyslog_level field (tag 12) to NetworkConfig protobuf
  • Wire the new config field to the existing Syslog::logMask() filtering mechanism via a new syslogLevelToMask() helper
  • Default behavior: UNSET (0) is treated as INFO, filtering out DEBUG messages

Motivation

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 Syslog class already has a _priMask filtering mechanism, but it was never wired to a user-configurable setting.

Changes

File Change
src/mesh/generated/meshtastic/config.pb.h Add LogLevel enum, rsyslog_level field, tags, FIELDLIST, init macros, size updates
src/DebugConfiguration.h Add syslogLevelToMask() inline helper function
src/mesh/eth/ethClient.cpp Apply logMask() during Ethernet syslog initialization
src/mesh/wifi/WiFiAPClient.cpp Apply logMask() during WiFi syslog initialization

Companion PR

Protobuf definition: meshtastic/protobufs#870

Backwards Compatibility

  • Default (UNSET = 0) maps to INFO level - existing devices will filter out DEBUG after upgrade
  • No breaking changes to wire format or existing config fields
  • Apps that don't set rsyslog_level get sensible default behavior

Test plan

  • Firmware builds successfully for rak4631_eth_gw
  • Verify DEBUG messages are filtered by default on rsyslog server
  • Set rsyslog_level to LOG_DEBUG and verify all messages appear
  • Set rsyslog_level to LOG_WARNING and verify only WARNING/ERROR/CRITICAL appear
  • Verify WiFi-based syslog filtering works on ESP32

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
@github-actions github-actions Bot added the enhancement New feature or request label Feb 27, 2026
meshtastic_Config_NetworkConfig_AddressMode_STATIC = 1
} meshtastic_Config_NetworkConfig_AddressMode;

/* Syslog log level to control which messages are sent to the rsyslog server.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please revert the change to the 'generated' file. This will casue ugly merge conflicts when the protos re re-generated

Comment thread src/DebugConfiguration.h
- 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
@PhilipLykov

Copy link
Copy Markdown
Contributor Author

@caveman99 Thanks for the review! Both points addressed in ca5a0e2:

1. Generated file revertedconfig.pb.h is now back to the upstream version. The proto definition lives in the companion PR meshtastic/protobufs#870. The rsyslog_level usage in firmware is now guarded with #ifdef meshtastic_Config_NetworkConfig_rsyslog_level_tag, so the code compiles cleanly with or without the proto field — defaulting to INFO when absent.

2. TRACE level — Made it an explicit case with a comment explaining that syslog has no native TRACE level, so it maps to SYSLOG_DEBUG (the most verbose syslog level available):

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.

@PhilipLykov PhilipLykov requested a review from caveman99 April 14, 2026 19:02
@llamafilm

Copy link
Copy Markdown

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.

@PhilipLykov

Copy link
Copy Markdown
Contributor Author

@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 rsyslog_server in the Meshtastic protobuf, so we named rsyslog_level to be consistent with that established convention. Renaming would be a separate discussion affecting the existing field as well.

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants