Skip to content

Commit

Permalink
feat: decrease websocket logging for known errors (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
bdraco authored Jun 22, 2024
1 parent 64ef106 commit 05df499
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions src/uiprotect/websocket.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,28 +76,23 @@ async def _websocket_loop(self) -> None:
level = logging.ERROR if self._seen_non_close_message else logging.DEBUG
if isinstance(ex, WSServerHandshakeError):
if ex.status == HTTPStatus.UNAUTHORIZED.value:
_LOGGER.log(level, "Websocket authentication error: %s", url)
await self._attempt_reauth()
else:
_LOGGER.log(
level, "Websocket handshake error: %s", url, exc_info=True
level, "Websocket authentication error: %s: %s", url, ex
)
await self._attempt_reauth()
else:
_LOGGER.log(level, "Websocket handshake error: %s: %s", url, ex)
else:
_LOGGER.log(
level, "Websocket disconnect error: %s", url, exc_info=True
)
_LOGGER.log(level, "Websocket disconnect error: %s: %s", url, ex)
except asyncio.TimeoutError:
level = logging.ERROR if self._seen_non_close_message else logging.DEBUG
_LOGGER.log(level, "Websocket timeout: %s", url)
except Exception:
_LOGGER.debug(
"Unexpected error in websocket reconnect loop, backoff: %s",
backoff,
exc_info=True,
)
_LOGGER.exception("Unexpected error in websocket loop")

if self._running is False:
break
_LOGGER.debug("Reconnecting websocket in %s seconds", backoff)
await asyncio.sleep(self.backoff)

async def _websocket_inner_loop(self, url: URL) -> None:
Expand Down

0 comments on commit 05df499

Please sign in to comment.