Skip to content

Bound Sonoff debug logging - #1853

Open
aferende wants to merge 1 commit into
AlexxIT:masterfrom
aferende:agent/bound-sonoff-debug-logging
Open

Bound Sonoff debug logging#1853
aferende wants to merge 1 commit into
AlexxIT:masterfrom
aferende:agent/bound-sonoff-debug-logging

Conversation

@aferende

@aferende aferende commented Aug 2, 2026

Copy link
Copy Markdown

Summary

The optional Sonoff debug view currently raises the integration logger to DEBUG and lets the protocol logger propagate to Home Assistant's raw log stream. Long-running debug mode can therefore write high-frequency Cloud/Local protocol traces to Home Assistant logs and, when configured, associated system-log/recorder processing.

This change keeps the existing bounded in-memory debug page while preventing protocol DEBUG records from propagating to Home Assistant's root handlers. WARNING and ERROR records are still explicitly forwarded, so actionable failures remain visible.

Changes

  • Add a warning/error passthrough handler for the Sonoff logger.
  • Disable propagation after attaching the optional debug view.
  • Stop mutating LogRecord.levelno as a side effect of debug capture.
  • Add regression coverage proving that a protocol debug trace stays in the view while an actionable warning reaches the root logger.

Impact

This makes temporary debugging safer for production Home Assistant installations: diagnostics remain available at the random debug-view URL, but protocol traffic no longer grows the raw log stream continuously.

Validation

  • python3 -m compileall -q custom_components tests
  • git diff --check

The regression test is included; the local environment used for this contribution does not have the project's pytest/Home Assistant test dependencies installed.

No configuration, credentials, device identifiers, or private-network information are included.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant