Skip to content

Commit bc72efc

Browse files
committed
Tidy up logging
1 parent 3bd9e5b commit bc72efc

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

src/lmstudio/_ws_impl.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -262,7 +262,7 @@ def __init__(
262262
self._ws_disconnected = asyncio.Event()
263263
self._rx_task: asyncio.Task[None] | None = None
264264
self._logger = logger = new_logger(type(self).__name__)
265-
logger.update_context(log_context)
265+
logger.update_context(log_context, ws_url=ws_url)
266266
self._mux = MultiplexingManager(logger)
267267

268268
async def connect(self) -> bool:
@@ -294,7 +294,7 @@ def disconnect_threadsafe(self) -> None:
294294
task_manager.run_coroutine_threadsafe(self.disconnect()).result()
295295

296296
async def _logged_ws_handler(self) -> None:
297-
self._logger.info("Websocket handling task started")
297+
self._logger.debug("Websocket handling task started")
298298
try:
299299
await self._handle_ws()
300300
except (asyncio.CancelledError, GeneratorExit):
@@ -306,7 +306,7 @@ async def _logged_ws_handler(self) -> None:
306306
# Ensure connections attempt are unblocked even if the
307307
# background async task errors out completely
308308
self._connection_attempted.set()
309-
self._logger.info("Websocket task terminated")
309+
self._logger.debug("Websocket task terminated")
310310

311311
async def _handle_ws(self) -> None:
312312
assert self._task_manager.check_running_in_task_loop()
@@ -330,12 +330,12 @@ def _clear_task_state() -> None:
330330
if not await self._authenticate():
331331
return
332332
self._connection_attempted.set()
333-
self._logger.info(f"Websocket session established ({self._ws_url})")
333+
self._logger.info("Websocket session established")
334334
# Task will run until message reception fails or is cancelled
335335
try:
336336
await self._receive_messages()
337337
finally:
338-
self._logger.info("Websocket demultiplexing task terminated.")
338+
self._logger.debug("Websocket demultiplexing task terminated.")
339339
# Notify foreground thread of background thread termination
340340
# (this covers termination due to link failure)
341341
await self.notify_client_termination()

src/lmstudio/async_api.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ async def __aexit__(self, *args: Any) -> None:
249249
async def connect(self) -> Self:
250250
"""Connect to and authenticate with the LM Studio API."""
251251
self._fail_if_connected("Attempted to connect already connected websocket")
252-
self._logger.info(f"Connecting websocket session ({self._ws_url})")
252+
self._logger.info("Connecting websocket session")
253253
ws_handler = self._ws_handler
254254
if not await self._ws_handler.connect():
255255
if ws_handler._connection_failure is not None:
@@ -265,7 +265,7 @@ async def disconnect(self) -> None:
265265
"""Drop the LM Studio API connection."""
266266
self._ws = None
267267
await self._ws_handler.disconnect()
268-
self._logger.info(f"Websocket session disconnected ({self._ws_url})")
268+
self._logger.info("Websocket session disconnected")
269269

270270
aclose = disconnect
271271

0 commit comments

Comments
 (0)