-
Notifications
You must be signed in to change notification settings - Fork 57
fix: Update logging to be more conservative #624
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -371,15 +371,24 @@ async def _background_reconnect(self) -> None: | |
|
|
||
| # Not connected, so wait with backoff before trying to connect. | ||
| # The first time through, we don't sleep, we just try to connect. | ||
| # We also only log after the first retry to avoid spamming logs. | ||
| local_connect_failures += 1 | ||
| if local_connect_failures > 1: | ||
| if local_connect_failures == 2: | ||
| _LOGGER.info( | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I worry someone may get confused by their logs if it stops showing it retrying. What if we did this every n reconnect failures?
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Or maybe just "will continue retrying" rather than giving a timeframe |
||
| "Local connection to device %s failed, retrying in %s seconds", | ||
| self._device_uid, | ||
| reconnect_backoff.total_seconds(), | ||
| ) | ||
| await asyncio.sleep(reconnect_backoff.total_seconds()) | ||
| reconnect_backoff = min(reconnect_backoff * RECONNECT_MULTIPLIER, MAX_RECONNECT_INTERVAL) | ||
|
|
||
| use_cache = self._should_use_cache(local_connect_failures) | ||
| await self._local_connect(prefer_cache=use_cache) | ||
| # Reset backoff and failures on success | ||
| reconnect_backoff = MIN_RECONNECT_INTERVAL | ||
| if local_connect_failures >= 2: | ||
| _LOGGER.info("Local connection to device %s re-established", self._device_uid) | ||
|
Comment on lines
+377
to
+391
|
||
| local_connect_failures = 0 | ||
|
|
||
| except asyncio.CancelledError: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The log level change from
warningtodebugwill break existing tests. Teststest_connection_lost_callbackandtest_connection_lost_without_exceptionintests/devices/test_local_channel.py(lines 231 and 245) check for "Connection lost" incaplog.text, butcaplogby default only captures WARNING level and above. These tests will need to be updated to either:caplog.set_level(logging.DEBUG)to capture debug logs, or