From 775b6832769a32752ef998dc84eb37c3cf52ca59 Mon Sep 17 00:00:00 2001 From: Noah Stapp Date: Thu, 8 May 2025 14:20:11 -0400 Subject: [PATCH] PYTHON-5371 - Pass repr(ServerDescription) to logging (#2329) --- pymongo/asynchronous/topology.py | 16 ++++++++-------- pymongo/synchronous/topology.py | 16 ++++++++-------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/pymongo/asynchronous/topology.py b/pymongo/asynchronous/topology.py index 438dd1e35..99b30fed1 100644 --- a/pymongo/asynchronous/topology.py +++ b/pymongo/asynchronous/topology.py @@ -154,8 +154,8 @@ class Topology: _SDAM_LOGGER, message=_SDAMStatusMessage.TOPOLOGY_CHANGE, topologyId=self._topology_id, - previousDescription=initial_td, - newDescription=self._description, + previousDescription=repr(initial_td), + newDescription=repr(self._description), ) for seed in topology_settings.seeds: @@ -514,8 +514,8 @@ class Topology: _SDAM_LOGGER, message=_SDAMStatusMessage.TOPOLOGY_CHANGE, topologyId=self._topology_id, - previousDescription=td_old, - newDescription=self._description, + previousDescription=repr(td_old), + newDescription=repr(self._description), ) # Shutdown SRV polling for unsupported cluster types. @@ -581,8 +581,8 @@ class Topology: _SDAM_LOGGER, message=_SDAMStatusMessage.TOPOLOGY_CHANGE, topologyId=self._topology_id, - previousDescription=td_old, - newDescription=self._description, + previousDescription=repr(td_old), + newDescription=repr(self._description), ) async def on_srv_update(self, seedlist: list[tuple[str, Any]]) -> None: @@ -747,8 +747,8 @@ class Topology: _SDAM_LOGGER, message=_SDAMStatusMessage.TOPOLOGY_CHANGE, topologyId=self._topology_id, - previousDescription=old_td, - newDescription=self._description, + previousDescription=repr(old_td), + newDescription=repr(self._description), ) _debug_log( _SDAM_LOGGER, message=_SDAMStatusMessage.STOP_TOPOLOGY, topologyId=self._topology_id diff --git a/pymongo/synchronous/topology.py b/pymongo/synchronous/topology.py index 1e99adf72..10d41def6 100644 --- a/pymongo/synchronous/topology.py +++ b/pymongo/synchronous/topology.py @@ -154,8 +154,8 @@ class Topology: _SDAM_LOGGER, message=_SDAMStatusMessage.TOPOLOGY_CHANGE, topologyId=self._topology_id, - previousDescription=initial_td, - newDescription=self._description, + previousDescription=repr(initial_td), + newDescription=repr(self._description), ) for seed in topology_settings.seeds: @@ -514,8 +514,8 @@ class Topology: _SDAM_LOGGER, message=_SDAMStatusMessage.TOPOLOGY_CHANGE, topologyId=self._topology_id, - previousDescription=td_old, - newDescription=self._description, + previousDescription=repr(td_old), + newDescription=repr(self._description), ) # Shutdown SRV polling for unsupported cluster types. @@ -581,8 +581,8 @@ class Topology: _SDAM_LOGGER, message=_SDAMStatusMessage.TOPOLOGY_CHANGE, topologyId=self._topology_id, - previousDescription=td_old, - newDescription=self._description, + previousDescription=repr(td_old), + newDescription=repr(self._description), ) def on_srv_update(self, seedlist: list[tuple[str, Any]]) -> None: @@ -745,8 +745,8 @@ class Topology: _SDAM_LOGGER, message=_SDAMStatusMessage.TOPOLOGY_CHANGE, topologyId=self._topology_id, - previousDescription=old_td, - newDescription=self._description, + previousDescription=repr(old_td), + newDescription=repr(self._description), ) _debug_log( _SDAM_LOGGER, message=_SDAMStatusMessage.STOP_TOPOLOGY, topologyId=self._topology_id