Skip to content

Commit b0c0d2b

Browse files
committed
fixup! refactor: sanitize log messages
- Use the same message arrow directions as in the Node library. - Also sanitize the incoming WS messages.
1 parent 12f597f commit b0c0d2b

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

ucapi/api.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ async def _enqueue_ws_payload(self, websocket, payload: dict[str, Any]) -> None:
389389

390390
if _LOG.isEnabledFor(logging.DEBUG):
391391
_LOG.debug(
392-
"[%s] ->: %s", websocket.remote_address, sanitize_json_message(payload)
392+
"[%s] <-: %s", websocket.remote_address, sanitize_json_message(payload)
393393
)
394394

395395
match payload.get("kind"):
@@ -513,7 +513,10 @@ async def _send_ws_event(
513513
await self._enqueue_ws_payload(websocket, data)
514514

515515
async def _process_ws_message(self, websocket, data: dict[str, Any]) -> None:
516-
_LOG.debug("[%s] <-: %s", websocket.remote_address, data)
516+
if _LOG.isEnabledFor(logging.DEBUG):
517+
_LOG.debug(
518+
"[%s] ->: %s", websocket.remote_address, sanitize_json_message(data)
519+
)
517520

518521
kind = data["kind"]
519522
req_id = data.get("id")
@@ -630,7 +633,7 @@ async def _process_ws_binary_message(self, websocket, data: bytes) -> None:
630633
"""
631634
if _LOG.isEnabledFor(logging.DEBUG):
632635
_LOG.debug(
633-
"[%s] <-: <binary %d bytes>", websocket.remote_address, len(data)
636+
"[%s] ->: <binary %d bytes>", websocket.remote_address, len(data)
634637
)
635638

636639
# Parse IntegrationMessage from bytes

0 commit comments

Comments
 (0)