Skip to content

Commit bd002b9

Browse files
committed
Pass ServerDescription.__repr__ to SDAM logging
1 parent e475143 commit bd002b9

File tree

4 files changed

+16
-18
lines changed

4 files changed

+16
-18
lines changed

pymongo/asynchronous/topology.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ def __init__(self, topology_settings: TopologySettings):
154154
_SDAM_LOGGER,
155155
message=_SDAMStatusMessage.TOPOLOGY_CHANGE,
156156
topologyId=self._topology_id,
157-
previousDescription=initial_td,
158-
newDescription=self._description,
157+
previousDescription=initial_td.__repr__(),
158+
newDescription=self._description.__repr__(),
159159
)
160160

161161
for seed in topology_settings.seeds:
@@ -514,8 +514,8 @@ async def _process_change(
514514
_SDAM_LOGGER,
515515
message=_SDAMStatusMessage.TOPOLOGY_CHANGE,
516516
topologyId=self._topology_id,
517-
previousDescription=td_old,
518-
newDescription=self._description,
517+
previousDescription=td_old.__repr__(),
518+
newDescription=self._description.__repr__(),
519519
)
520520

521521
# Shutdown SRV polling for unsupported cluster types.
@@ -581,8 +581,8 @@ async def _process_srv_update(self, seedlist: list[tuple[str, Any]]) -> None:
581581
_SDAM_LOGGER,
582582
message=_SDAMStatusMessage.TOPOLOGY_CHANGE,
583583
topologyId=self._topology_id,
584-
previousDescription=td_old,
585-
newDescription=self._description,
584+
previousDescription=td_old.__repr__(),
585+
newDescription=self._description.__repr__(),
586586
)
587587

588588
async def on_srv_update(self, seedlist: list[tuple[str, Any]]) -> None:
@@ -747,8 +747,8 @@ async def close(self) -> None:
747747
_SDAM_LOGGER,
748748
message=_SDAMStatusMessage.TOPOLOGY_CHANGE,
749749
topologyId=self._topology_id,
750-
previousDescription=old_td,
751-
newDescription=self._description,
750+
previousDescription=old_td.__repr__(),
751+
newDescription=self._description.__repr__(),
752752
)
753753
_debug_log(
754754
_SDAM_LOGGER, message=_SDAMStatusMessage.STOP_TOPOLOGY, topologyId=self._topology_id

pymongo/synchronous/topology.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -154,8 +154,8 @@ def __init__(self, topology_settings: TopologySettings):
154154
_SDAM_LOGGER,
155155
message=_SDAMStatusMessage.TOPOLOGY_CHANGE,
156156
topologyId=self._topology_id,
157-
previousDescription=initial_td,
158-
newDescription=self._description,
157+
previousDescription=initial_td.__repr__(),
158+
newDescription=self._description.__repr__(),
159159
)
160160

161161
for seed in topology_settings.seeds:
@@ -514,8 +514,8 @@ def _process_change(
514514
_SDAM_LOGGER,
515515
message=_SDAMStatusMessage.TOPOLOGY_CHANGE,
516516
topologyId=self._topology_id,
517-
previousDescription=td_old,
518-
newDescription=self._description,
517+
previousDescription=td_old.__repr__(),
518+
newDescription=self._description.__repr__(),
519519
)
520520

521521
# Shutdown SRV polling for unsupported cluster types.
@@ -581,8 +581,8 @@ def _process_srv_update(self, seedlist: list[tuple[str, Any]]) -> None:
581581
_SDAM_LOGGER,
582582
message=_SDAMStatusMessage.TOPOLOGY_CHANGE,
583583
topologyId=self._topology_id,
584-
previousDescription=td_old,
585-
newDescription=self._description,
584+
previousDescription=td_old.__repr__(),
585+
newDescription=self._description.__repr__(),
586586
)
587587

588588
def on_srv_update(self, seedlist: list[tuple[str, Any]]) -> None:
@@ -745,8 +745,8 @@ def close(self) -> None:
745745
_SDAM_LOGGER,
746746
message=_SDAMStatusMessage.TOPOLOGY_CHANGE,
747747
topologyId=self._topology_id,
748-
previousDescription=old_td,
749-
newDescription=self._description,
748+
previousDescription=old_td.__repr__(),
749+
newDescription=self._description.__repr__(),
750750
)
751751
_debug_log(
752752
_SDAM_LOGGER, message=_SDAMStatusMessage.STOP_TOPOLOGY, topologyId=self._topology_id

test/asynchronous/test_client.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1906,7 +1906,6 @@ async def test_direct_connection(self):
19061906
with self.assertRaises(ConfigurationError):
19071907
AsyncMongoClient(["host1", "host2"], directConnection=True)
19081908

1909-
@unittest.skipIf(os.environ.get("DEBUG_LOG"), "Enabling debug logs breaks this test")
19101909
@unittest.skipIf("PyPy" in sys.version, "PYTHON-2927 fails often on PyPy")
19111910
async def test_continuous_network_errors(self):
19121911
def server_description_count():

test/test_client.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1863,7 +1863,6 @@ def test_direct_connection(self):
18631863
with self.assertRaises(ConfigurationError):
18641864
MongoClient(["host1", "host2"], directConnection=True)
18651865

1866-
@unittest.skipIf(os.environ.get("DEBUG_LOG"), "Enabling debug logs breaks this test")
18671866
@unittest.skipIf("PyPy" in sys.version, "PYTHON-2927 fails often on PyPy")
18681867
def test_continuous_network_errors(self):
18691868
def server_description_count():

0 commit comments

Comments
 (0)