Skip to content

Commit 947b81f

Browse files
committed
Uniformize debug logging calls.
1 parent c19da91 commit 947b81f

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/websockets/legacy/protocol.py

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1231,7 +1231,8 @@ async def keepalive_ping(self) -> None:
12311231
while True:
12321232
await asyncio.sleep(self.ping_interval)
12331233

1234-
self.logger.debug("% sending keepalive ping")
1234+
if self.debug:
1235+
self.logger.debug("% sending keepalive ping")
12351236
pong_waiter = await self.ping()
12361237

12371238
if self.ping_timeout is not None:
@@ -1242,7 +1243,8 @@ async def keepalive_ping(self) -> None:
12421243
# Raises ConnectionClosed if the connection is lost,
12431244
# when connection_lost() calls abort_pings().
12441245
await pong_waiter
1245-
self.logger.debug("% received keepalive pong")
1246+
if self.debug:
1247+
self.logger.debug("% received keepalive pong")
12461248
except asyncio.TimeoutError:
12471249
if self.debug:
12481250
self.logger.debug("- timed out waiting for keepalive pong")
@@ -1469,7 +1471,8 @@ def connection_lost(self, exc: Exception | None) -> None:
14691471
14701472
"""
14711473
self.state = State.CLOSED
1472-
self.logger.debug("= connection is CLOSED")
1474+
if self.debug:
1475+
self.logger.debug("= connection is CLOSED")
14731476

14741477
self.abort_pings()
14751478

0 commit comments

Comments
 (0)