diff --git a/pymongo/asynchronous/bulk.py b/pymongo/asynchronous/bulk.py index 91e08f61b3..ac514db98f 100644 --- a/pymongo/asynchronous/bulk.py +++ b/pymongo/asynchronous/bulk.py @@ -255,8 +255,8 @@ async def write_command( if _COMMAND_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _COMMAND_LOGGER, - clientId=client._topology_settings._topology_id, message=_CommandStatusMessage.STARTED, + clientId=client._topology_settings._topology_id, command=cmd, commandName=next(iter(cmd)), databaseName=bwc.db_name, @@ -276,8 +276,8 @@ async def write_command( if _COMMAND_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _COMMAND_LOGGER, - clientId=client._topology_settings._topology_id, message=_CommandStatusMessage.SUCCEEDED, + clientId=client._topology_settings._topology_id, durationMS=duration, reply=reply, commandName=next(iter(cmd)), @@ -302,8 +302,8 @@ async def write_command( if _COMMAND_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _COMMAND_LOGGER, - clientId=client._topology_settings._topology_id, message=_CommandStatusMessage.FAILED, + clientId=client._topology_settings._topology_id, durationMS=duration, failure=failure, commandName=next(iter(cmd)), @@ -340,8 +340,8 @@ async def unack_write( if _COMMAND_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _COMMAND_LOGGER, - clientId=client._topology_settings._topology_id, message=_CommandStatusMessage.STARTED, + clientId=client._topology_settings._topology_id, command=cmd, commandName=next(iter(cmd)), databaseName=bwc.db_name, @@ -366,8 +366,8 @@ async def unack_write( if _COMMAND_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _COMMAND_LOGGER, - clientId=client._topology_settings._topology_id, message=_CommandStatusMessage.SUCCEEDED, + clientId=client._topology_settings._topology_id, durationMS=duration, reply=reply, commandName=next(iter(cmd)), @@ -393,8 +393,8 @@ async def unack_write( if _COMMAND_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _COMMAND_LOGGER, - clientId=client._topology_settings._topology_id, message=_CommandStatusMessage.FAILED, + clientId=client._topology_settings._topology_id, durationMS=duration, failure=failure, commandName=next(iter(cmd)), diff --git a/pymongo/asynchronous/client_bulk.py b/pymongo/asynchronous/client_bulk.py index 1100527552..5f7ac013e9 100644 --- a/pymongo/asynchronous/client_bulk.py +++ b/pymongo/asynchronous/client_bulk.py @@ -241,8 +241,8 @@ async def write_command( if _COMMAND_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _COMMAND_LOGGER, - clientId=client._topology_settings._topology_id, message=_CommandStatusMessage.STARTED, + clientId=client._topology_settings._topology_id, command=cmd, commandName=next(iter(cmd)), databaseName=bwc.db_name, @@ -262,8 +262,8 @@ async def write_command( if _COMMAND_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _COMMAND_LOGGER, - clientId=client._topology_settings._topology_id, message=_CommandStatusMessage.SUCCEEDED, + clientId=client._topology_settings._topology_id, durationMS=duration, reply=reply, commandName=next(iter(cmd)), @@ -289,8 +289,8 @@ async def write_command( if _COMMAND_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _COMMAND_LOGGER, - clientId=client._topology_settings._topology_id, message=_CommandStatusMessage.FAILED, + clientId=client._topology_settings._topology_id, durationMS=duration, failure=failure, commandName=next(iter(cmd)), @@ -330,8 +330,8 @@ async def unack_write( if _COMMAND_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _COMMAND_LOGGER, - clientId=client._topology_settings._topology_id, message=_CommandStatusMessage.STARTED, + clientId=client._topology_settings._topology_id, command=cmd, commandName=next(iter(cmd)), databaseName=bwc.db_name, @@ -356,8 +356,8 @@ async def unack_write( if _COMMAND_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _COMMAND_LOGGER, - clientId=client._topology_settings._topology_id, message=_CommandStatusMessage.SUCCEEDED, + clientId=client._topology_settings._topology_id, durationMS=duration, reply=reply, commandName=next(iter(cmd)), @@ -383,8 +383,8 @@ async def unack_write( if _COMMAND_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _COMMAND_LOGGER, - clientId=client._topology_settings._topology_id, message=_CommandStatusMessage.FAILED, + clientId=client._topology_settings._topology_id, durationMS=duration, failure=failure, commandName=next(iter(cmd)), diff --git a/pymongo/asynchronous/monitor.py b/pymongo/asynchronous/monitor.py index 479ca1a314..32b545380a 100644 --- a/pymongo/asynchronous/monitor.py +++ b/pymongo/asynchronous/monitor.py @@ -274,6 +274,7 @@ async def _check_server(self) -> ServerDescription: if _SDAM_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _SDAM_LOGGER, + message=_SDAMStatusMessage.HEARTBEAT_FAIL, topologyId=self._topology._topology_id, serverHost=address[0], serverPort=address[1], @@ -281,7 +282,6 @@ async def _check_server(self) -> ServerDescription: durationMS=duration * 1000, failure=error, driverConnectionId=self._conn_id, - message=_SDAMStatusMessage.HEARTBEAT_FAIL, ) await self._reset_connection() if isinstance(error, _OperationCancelled): @@ -313,13 +313,13 @@ async def _check_once(self) -> ServerDescription: if _SDAM_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _SDAM_LOGGER, + message=_SDAMStatusMessage.HEARTBEAT_START, topologyId=self._topology._topology_id, driverConnectionId=conn.id, serverConnectionId=conn.server_connection_id, serverHost=address[0], serverPort=address[1], awaited=awaited, - message=_SDAMStatusMessage.HEARTBEAT_START, ) self._cancel_context = conn.cancel_context @@ -339,6 +339,7 @@ async def _check_once(self) -> ServerDescription: if _SDAM_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _SDAM_LOGGER, + message=_SDAMStatusMessage.HEARTBEAT_SUCCESS, topologyId=self._topology._topology_id, driverConnectionId=conn.id, serverConnectionId=conn.server_connection_id, @@ -347,7 +348,6 @@ async def _check_once(self) -> ServerDescription: awaited=awaited, durationMS=round_trip_time * 1000, reply=response.document, - message=_SDAMStatusMessage.HEARTBEAT_SUCCESS, ) return sd diff --git a/pymongo/asynchronous/network.py b/pymongo/asynchronous/network.py index 5f14bef45d..1605efe92d 100644 --- a/pymongo/asynchronous/network.py +++ b/pymongo/asynchronous/network.py @@ -163,8 +163,8 @@ async def command( if _COMMAND_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _COMMAND_LOGGER, - clientId=client._topology_settings._topology_id, message=_CommandStatusMessage.STARTED, + clientId=client._topology_settings._topology_id, command=spec, commandName=next(iter(spec)), databaseName=dbname, @@ -225,8 +225,8 @@ async def command( if _COMMAND_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _COMMAND_LOGGER, - clientId=client._topology_settings._topology_id, message=_CommandStatusMessage.FAILED, + clientId=client._topology_settings._topology_id, durationMS=duration, failure=failure, commandName=next(iter(spec)), @@ -259,8 +259,8 @@ async def command( if _COMMAND_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _COMMAND_LOGGER, - clientId=client._topology_settings._topology_id, message=_CommandStatusMessage.SUCCEEDED, + clientId=client._topology_settings._topology_id, durationMS=duration, reply=response_doc, commandName=next(iter(spec)), diff --git a/pymongo/asynchronous/pool.py b/pymongo/asynchronous/pool.py index 6ebdb5cb20..18644cf7de 100644 --- a/pymongo/asynchronous/pool.py +++ b/pymongo/asynchronous/pool.py @@ -528,8 +528,8 @@ async def authenticate(self, reauthenticate: bool = False) -> None: if self.enabled_for_logging and _CONNECTION_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _CONNECTION_LOGGER, - clientId=self._client_id, message=_ConnectionStatusMessage.CONN_READY, + clientId=self._client_id, serverHost=self.address[0], serverPort=self.address[1], driverConnectionId=self.id, @@ -561,8 +561,8 @@ async def close_conn(self, reason: Optional[str]) -> None: if self.enabled_for_logging and _CONNECTION_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _CONNECTION_LOGGER, - clientId=self._client_id, message=_ConnectionStatusMessage.CONN_CLOSED, + clientId=self._client_id, serverHost=self.address[0], serverPort=self.address[1], driverConnectionId=self.id, @@ -777,8 +777,8 @@ def __init__( if self.enabled_for_logging and _CONNECTION_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _CONNECTION_LOGGER, - clientId=self._client_id, message=_ConnectionStatusMessage.POOL_CREATED, + clientId=self._client_id, serverHost=self.address[0], serverPort=self.address[1], **self.opts.non_default_options, @@ -803,8 +803,8 @@ async def ready(self) -> None: if self.enabled_for_logging and _CONNECTION_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _CONNECTION_LOGGER, - clientId=self._client_id, message=_ConnectionStatusMessage.POOL_READY, + clientId=self._client_id, serverHost=self.address[0], serverPort=self.address[1], ) @@ -868,8 +868,8 @@ async def _reset( if self.enabled_for_logging and _CONNECTION_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _CONNECTION_LOGGER, - clientId=self._client_id, message=_ConnectionStatusMessage.POOL_CLOSED, + clientId=self._client_id, serverHost=self.address[0], serverPort=self.address[1], ) @@ -885,8 +885,8 @@ async def _reset( if self.enabled_for_logging and _CONNECTION_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _CONNECTION_LOGGER, - clientId=self._client_id, message=_ConnectionStatusMessage.POOL_CLEARED, + clientId=self._client_id, serverHost=self.address[0], serverPort=self.address[1], serviceId=service_id, @@ -998,8 +998,8 @@ async def connect(self, handler: Optional[_MongoClientErrorHandler] = None) -> A if self.enabled_for_logging and _CONNECTION_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _CONNECTION_LOGGER, - clientId=self._client_id, message=_ConnectionStatusMessage.CONN_CREATED, + clientId=self._client_id, serverHost=self.address[0], serverPort=self.address[1], driverConnectionId=conn_id, @@ -1019,8 +1019,8 @@ async def connect(self, handler: Optional[_MongoClientErrorHandler] = None) -> A if self.enabled_for_logging and _CONNECTION_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _CONNECTION_LOGGER, - clientId=self._client_id, message=_ConnectionStatusMessage.CONN_CLOSED, + clientId=self._client_id, serverHost=self.address[0], serverPort=self.address[1], driverConnectionId=conn_id, @@ -1086,8 +1086,8 @@ async def checkout( if self.enabled_for_logging and _CONNECTION_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _CONNECTION_LOGGER, - clientId=self._client_id, message=_ConnectionStatusMessage.CHECKOUT_STARTED, + clientId=self._client_id, serverHost=self.address[0], serverPort=self.address[1], ) @@ -1101,8 +1101,8 @@ async def checkout( if self.enabled_for_logging and _CONNECTION_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _CONNECTION_LOGGER, - clientId=self._client_id, message=_ConnectionStatusMessage.CHECKOUT_SUCCEEDED, + clientId=self._client_id, serverHost=self.address[0], serverPort=self.address[1], driverConnectionId=conn.id, @@ -1150,8 +1150,8 @@ def _raise_if_not_ready(self, checkout_started_time: float, emit_event: bool) -> if self.enabled_for_logging and _CONNECTION_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _CONNECTION_LOGGER, - clientId=self._client_id, message=_ConnectionStatusMessage.CHECKOUT_FAILED, + clientId=self._client_id, serverHost=self.address[0], serverPort=self.address[1], reason="An error occurred while trying to establish a new connection", @@ -1184,8 +1184,8 @@ async def _get_conn( if self.enabled_for_logging and _CONNECTION_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _CONNECTION_LOGGER, - clientId=self._client_id, message=_ConnectionStatusMessage.CHECKOUT_FAILED, + clientId=self._client_id, serverHost=self.address[0], serverPort=self.address[1], reason="Connection pool was closed", @@ -1280,8 +1280,8 @@ async def _get_conn( if self.enabled_for_logging and _CONNECTION_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _CONNECTION_LOGGER, - clientId=self._client_id, message=_ConnectionStatusMessage.CHECKOUT_FAILED, + clientId=self._client_id, serverHost=self.address[0], serverPort=self.address[1], reason="An error occurred while trying to establish a new connection", @@ -1313,8 +1313,8 @@ async def checkin(self, conn: AsyncConnection) -> None: if self.enabled_for_logging and _CONNECTION_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _CONNECTION_LOGGER, - clientId=self._client_id, message=_ConnectionStatusMessage.CHECKEDIN, + clientId=self._client_id, serverHost=self.address[0], serverPort=self.address[1], driverConnectionId=conn.id, @@ -1334,8 +1334,8 @@ async def checkin(self, conn: AsyncConnection) -> None: if self.enabled_for_logging and _CONNECTION_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _CONNECTION_LOGGER, - clientId=self._client_id, message=_ConnectionStatusMessage.CONN_CLOSED, + clientId=self._client_id, serverHost=self.address[0], serverPort=self.address[1], driverConnectionId=conn.id, @@ -1412,8 +1412,8 @@ def _raise_wait_queue_timeout(self, checkout_started_time: float) -> NoReturn: if self.enabled_for_logging and _CONNECTION_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _CONNECTION_LOGGER, - clientId=self._client_id, message=_ConnectionStatusMessage.CHECKOUT_FAILED, + clientId=self._client_id, serverHost=self.address[0], serverPort=self.address[1], reason="Wait queue timeout elapsed without a connection becoming available", diff --git a/pymongo/asynchronous/server.py b/pymongo/asynchronous/server.py index 3ad8374b00..0e0d53b96f 100644 --- a/pymongo/asynchronous/server.py +++ b/pymongo/asynchronous/server.py @@ -108,10 +108,10 @@ async def close(self) -> None: if _SDAM_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _SDAM_LOGGER, + message=_SDAMStatusMessage.STOP_SERVER, topologyId=self._topology_id, serverHost=self._description.address[0], serverPort=self._description.address[1], - message=_SDAMStatusMessage.STOP_SERVER, ) await self._monitor.close() @@ -173,8 +173,8 @@ async def run_operation( if _COMMAND_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _COMMAND_LOGGER, - clientId=client._topology_settings._topology_id, message=_CommandStatusMessage.STARTED, + clientId=client._topology_settings._topology_id, command=cmd, commandName=next(iter(cmd)), databaseName=dbn, @@ -234,8 +234,8 @@ async def run_operation( if _COMMAND_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _COMMAND_LOGGER, - clientId=client._topology_settings._topology_id, message=_CommandStatusMessage.FAILED, + clientId=client._topology_settings._topology_id, durationMS=duration, failure=failure, commandName=next(iter(cmd)), @@ -278,8 +278,8 @@ async def run_operation( if _COMMAND_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _COMMAND_LOGGER, - clientId=client._topology_settings._topology_id, message=_CommandStatusMessage.SUCCEEDED, + clientId=client._topology_settings._topology_id, durationMS=duration, reply=res, commandName=next(iter(cmd)), diff --git a/pymongo/asynchronous/topology.py b/pymongo/asynchronous/topology.py index d83ceca55b..9de069af7e 100644 --- a/pymongo/asynchronous/topology.py +++ b/pymongo/asynchronous/topology.py @@ -120,8 +120,8 @@ def __init__(self, topology_settings: TopologySettings): if _SDAM_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _SDAM_LOGGER, - topologyId=self._topology_id, message=_SDAMStatusMessage.START_TOPOLOGY, + topologyId=self._topology_id, ) if self._publish_tp: @@ -152,10 +152,10 @@ def __init__(self, topology_settings: TopologySettings): if _SDAM_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _SDAM_LOGGER, + message=_SDAMStatusMessage.TOPOLOGY_CHANGE, topologyId=self._topology_id, previousDescription=initial_td, newDescription=self._description, - message=_SDAMStatusMessage.TOPOLOGY_CHANGE, ) for seed in topology_settings.seeds: @@ -165,10 +165,10 @@ def __init__(self, topology_settings: TopologySettings): if _SDAM_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _SDAM_LOGGER, + message=_SDAMStatusMessage.START_SERVER, topologyId=self._topology_id, serverHost=seed[0], serverPort=seed[1], - message=_SDAMStatusMessage.START_SERVER, ) # Store the seed list to help diagnose errors in _error_message(). @@ -514,10 +514,10 @@ async def _process_change( if _SDAM_LOGGER.isEnabledFor(logging.DEBUG) and not suppress_event: _debug_log( _SDAM_LOGGER, + message=_SDAMStatusMessage.TOPOLOGY_CHANGE, topologyId=self._topology_id, previousDescription=td_old, newDescription=self._description, - message=_SDAMStatusMessage.TOPOLOGY_CHANGE, ) # Shutdown SRV polling for unsupported cluster types. @@ -582,10 +582,10 @@ async def _process_srv_update(self, seedlist: list[tuple[str, Any]]) -> None: if _SDAM_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _SDAM_LOGGER, + message=_SDAMStatusMessage.TOPOLOGY_CHANGE, topologyId=self._topology_id, previousDescription=td_old, newDescription=self._description, - message=_SDAMStatusMessage.TOPOLOGY_CHANGE, ) async def on_srv_update(self, seedlist: list[tuple[str, Any]]) -> None: @@ -748,13 +748,13 @@ async def close(self) -> None: if _SDAM_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _SDAM_LOGGER, + message=_SDAMStatusMessage.TOPOLOGY_CHANGE, topologyId=self._topology_id, previousDescription=old_td, newDescription=self._description, - message=_SDAMStatusMessage.TOPOLOGY_CHANGE, ) _debug_log( - _SDAM_LOGGER, topologyId=self._topology_id, message=_SDAMStatusMessage.STOP_TOPOLOGY + _SDAM_LOGGER, message=_SDAMStatusMessage.STOP_TOPOLOGY, topologyId=self._topology_id ) if self._publish_server or self._publish_tp: diff --git a/pymongo/synchronous/bulk.py b/pymongo/synchronous/bulk.py index 3823ef354d..a528b09add 100644 --- a/pymongo/synchronous/bulk.py +++ b/pymongo/synchronous/bulk.py @@ -255,8 +255,8 @@ def write_command( if _COMMAND_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _COMMAND_LOGGER, - clientId=client._topology_settings._topology_id, message=_CommandStatusMessage.STARTED, + clientId=client._topology_settings._topology_id, command=cmd, commandName=next(iter(cmd)), databaseName=bwc.db_name, @@ -276,8 +276,8 @@ def write_command( if _COMMAND_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _COMMAND_LOGGER, - clientId=client._topology_settings._topology_id, message=_CommandStatusMessage.SUCCEEDED, + clientId=client._topology_settings._topology_id, durationMS=duration, reply=reply, commandName=next(iter(cmd)), @@ -302,8 +302,8 @@ def write_command( if _COMMAND_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _COMMAND_LOGGER, - clientId=client._topology_settings._topology_id, message=_CommandStatusMessage.FAILED, + clientId=client._topology_settings._topology_id, durationMS=duration, failure=failure, commandName=next(iter(cmd)), @@ -340,8 +340,8 @@ def unack_write( if _COMMAND_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _COMMAND_LOGGER, - clientId=client._topology_settings._topology_id, message=_CommandStatusMessage.STARTED, + clientId=client._topology_settings._topology_id, command=cmd, commandName=next(iter(cmd)), databaseName=bwc.db_name, @@ -366,8 +366,8 @@ def unack_write( if _COMMAND_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _COMMAND_LOGGER, - clientId=client._topology_settings._topology_id, message=_CommandStatusMessage.SUCCEEDED, + clientId=client._topology_settings._topology_id, durationMS=duration, reply=reply, commandName=next(iter(cmd)), @@ -393,8 +393,8 @@ def unack_write( if _COMMAND_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _COMMAND_LOGGER, - clientId=client._topology_settings._topology_id, message=_CommandStatusMessage.FAILED, + clientId=client._topology_settings._topology_id, durationMS=duration, failure=failure, commandName=next(iter(cmd)), diff --git a/pymongo/synchronous/client_bulk.py b/pymongo/synchronous/client_bulk.py index e6de22d237..d73bfb2a2b 100644 --- a/pymongo/synchronous/client_bulk.py +++ b/pymongo/synchronous/client_bulk.py @@ -241,8 +241,8 @@ def write_command( if _COMMAND_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _COMMAND_LOGGER, - clientId=client._topology_settings._topology_id, message=_CommandStatusMessage.STARTED, + clientId=client._topology_settings._topology_id, command=cmd, commandName=next(iter(cmd)), databaseName=bwc.db_name, @@ -262,8 +262,8 @@ def write_command( if _COMMAND_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _COMMAND_LOGGER, - clientId=client._topology_settings._topology_id, message=_CommandStatusMessage.SUCCEEDED, + clientId=client._topology_settings._topology_id, durationMS=duration, reply=reply, commandName=next(iter(cmd)), @@ -289,8 +289,8 @@ def write_command( if _COMMAND_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _COMMAND_LOGGER, - clientId=client._topology_settings._topology_id, message=_CommandStatusMessage.FAILED, + clientId=client._topology_settings._topology_id, durationMS=duration, failure=failure, commandName=next(iter(cmd)), @@ -330,8 +330,8 @@ def unack_write( if _COMMAND_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _COMMAND_LOGGER, - clientId=client._topology_settings._topology_id, message=_CommandStatusMessage.STARTED, + clientId=client._topology_settings._topology_id, command=cmd, commandName=next(iter(cmd)), databaseName=bwc.db_name, @@ -356,8 +356,8 @@ def unack_write( if _COMMAND_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _COMMAND_LOGGER, - clientId=client._topology_settings._topology_id, message=_CommandStatusMessage.SUCCEEDED, + clientId=client._topology_settings._topology_id, durationMS=duration, reply=reply, commandName=next(iter(cmd)), @@ -383,8 +383,8 @@ def unack_write( if _COMMAND_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _COMMAND_LOGGER, - clientId=client._topology_settings._topology_id, message=_CommandStatusMessage.FAILED, + clientId=client._topology_settings._topology_id, durationMS=duration, failure=failure, commandName=next(iter(cmd)), diff --git a/pymongo/synchronous/monitor.py b/pymongo/synchronous/monitor.py index 1413bb1437..f41040801f 100644 --- a/pymongo/synchronous/monitor.py +++ b/pymongo/synchronous/monitor.py @@ -272,6 +272,7 @@ def _check_server(self) -> ServerDescription: if _SDAM_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _SDAM_LOGGER, + message=_SDAMStatusMessage.HEARTBEAT_FAIL, topologyId=self._topology._topology_id, serverHost=address[0], serverPort=address[1], @@ -279,7 +280,6 @@ def _check_server(self) -> ServerDescription: durationMS=duration * 1000, failure=error, driverConnectionId=self._conn_id, - message=_SDAMStatusMessage.HEARTBEAT_FAIL, ) self._reset_connection() if isinstance(error, _OperationCancelled): @@ -311,13 +311,13 @@ def _check_once(self) -> ServerDescription: if _SDAM_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _SDAM_LOGGER, + message=_SDAMStatusMessage.HEARTBEAT_START, topologyId=self._topology._topology_id, driverConnectionId=conn.id, serverConnectionId=conn.server_connection_id, serverHost=address[0], serverPort=address[1], awaited=awaited, - message=_SDAMStatusMessage.HEARTBEAT_START, ) self._cancel_context = conn.cancel_context @@ -337,6 +337,7 @@ def _check_once(self) -> ServerDescription: if _SDAM_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _SDAM_LOGGER, + message=_SDAMStatusMessage.HEARTBEAT_SUCCESS, topologyId=self._topology._topology_id, driverConnectionId=conn.id, serverConnectionId=conn.server_connection_id, @@ -345,7 +346,6 @@ def _check_once(self) -> ServerDescription: awaited=awaited, durationMS=round_trip_time * 1000, reply=response.document, - message=_SDAMStatusMessage.HEARTBEAT_SUCCESS, ) return sd diff --git a/pymongo/synchronous/network.py b/pymongo/synchronous/network.py index 786edb7003..9559a5a542 100644 --- a/pymongo/synchronous/network.py +++ b/pymongo/synchronous/network.py @@ -163,8 +163,8 @@ def command( if _COMMAND_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _COMMAND_LOGGER, - clientId=client._topology_settings._topology_id, message=_CommandStatusMessage.STARTED, + clientId=client._topology_settings._topology_id, command=spec, commandName=next(iter(spec)), databaseName=dbname, @@ -225,8 +225,8 @@ def command( if _COMMAND_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _COMMAND_LOGGER, - clientId=client._topology_settings._topology_id, message=_CommandStatusMessage.FAILED, + clientId=client._topology_settings._topology_id, durationMS=duration, failure=failure, commandName=next(iter(spec)), @@ -259,8 +259,8 @@ def command( if _COMMAND_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _COMMAND_LOGGER, - clientId=client._topology_settings._topology_id, message=_CommandStatusMessage.SUCCEEDED, + clientId=client._topology_settings._topology_id, durationMS=duration, reply=response_doc, commandName=next(iter(spec)), diff --git a/pymongo/synchronous/pool.py b/pymongo/synchronous/pool.py index 6a302e2728..1151776b94 100644 --- a/pymongo/synchronous/pool.py +++ b/pymongo/synchronous/pool.py @@ -528,8 +528,8 @@ def authenticate(self, reauthenticate: bool = False) -> None: if self.enabled_for_logging and _CONNECTION_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _CONNECTION_LOGGER, - clientId=self._client_id, message=_ConnectionStatusMessage.CONN_READY, + clientId=self._client_id, serverHost=self.address[0], serverPort=self.address[1], driverConnectionId=self.id, @@ -559,8 +559,8 @@ def close_conn(self, reason: Optional[str]) -> None: if self.enabled_for_logging and _CONNECTION_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _CONNECTION_LOGGER, - clientId=self._client_id, message=_ConnectionStatusMessage.CONN_CLOSED, + clientId=self._client_id, serverHost=self.address[0], serverPort=self.address[1], driverConnectionId=self.id, @@ -775,8 +775,8 @@ def __init__( if self.enabled_for_logging and _CONNECTION_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _CONNECTION_LOGGER, - clientId=self._client_id, message=_ConnectionStatusMessage.POOL_CREATED, + clientId=self._client_id, serverHost=self.address[0], serverPort=self.address[1], **self.opts.non_default_options, @@ -801,8 +801,8 @@ def ready(self) -> None: if self.enabled_for_logging and _CONNECTION_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _CONNECTION_LOGGER, - clientId=self._client_id, message=_ConnectionStatusMessage.POOL_READY, + clientId=self._client_id, serverHost=self.address[0], serverPort=self.address[1], ) @@ -866,8 +866,8 @@ def _reset( if self.enabled_for_logging and _CONNECTION_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _CONNECTION_LOGGER, - clientId=self._client_id, message=_ConnectionStatusMessage.POOL_CLOSED, + clientId=self._client_id, serverHost=self.address[0], serverPort=self.address[1], ) @@ -883,8 +883,8 @@ def _reset( if self.enabled_for_logging and _CONNECTION_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _CONNECTION_LOGGER, - clientId=self._client_id, message=_ConnectionStatusMessage.POOL_CLEARED, + clientId=self._client_id, serverHost=self.address[0], serverPort=self.address[1], serviceId=service_id, @@ -994,8 +994,8 @@ def connect(self, handler: Optional[_MongoClientErrorHandler] = None) -> Connect if self.enabled_for_logging and _CONNECTION_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _CONNECTION_LOGGER, - clientId=self._client_id, message=_ConnectionStatusMessage.CONN_CREATED, + clientId=self._client_id, serverHost=self.address[0], serverPort=self.address[1], driverConnectionId=conn_id, @@ -1015,8 +1015,8 @@ def connect(self, handler: Optional[_MongoClientErrorHandler] = None) -> Connect if self.enabled_for_logging and _CONNECTION_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _CONNECTION_LOGGER, - clientId=self._client_id, message=_ConnectionStatusMessage.CONN_CLOSED, + clientId=self._client_id, serverHost=self.address[0], serverPort=self.address[1], driverConnectionId=conn_id, @@ -1082,8 +1082,8 @@ def checkout( if self.enabled_for_logging and _CONNECTION_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _CONNECTION_LOGGER, - clientId=self._client_id, message=_ConnectionStatusMessage.CHECKOUT_STARTED, + clientId=self._client_id, serverHost=self.address[0], serverPort=self.address[1], ) @@ -1097,8 +1097,8 @@ def checkout( if self.enabled_for_logging and _CONNECTION_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _CONNECTION_LOGGER, - clientId=self._client_id, message=_ConnectionStatusMessage.CHECKOUT_SUCCEEDED, + clientId=self._client_id, serverHost=self.address[0], serverPort=self.address[1], driverConnectionId=conn.id, @@ -1146,8 +1146,8 @@ def _raise_if_not_ready(self, checkout_started_time: float, emit_event: bool) -> if self.enabled_for_logging and _CONNECTION_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _CONNECTION_LOGGER, - clientId=self._client_id, message=_ConnectionStatusMessage.CHECKOUT_FAILED, + clientId=self._client_id, serverHost=self.address[0], serverPort=self.address[1], reason="An error occurred while trying to establish a new connection", @@ -1180,8 +1180,8 @@ def _get_conn( if self.enabled_for_logging and _CONNECTION_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _CONNECTION_LOGGER, - clientId=self._client_id, message=_ConnectionStatusMessage.CHECKOUT_FAILED, + clientId=self._client_id, serverHost=self.address[0], serverPort=self.address[1], reason="Connection pool was closed", @@ -1276,8 +1276,8 @@ def _get_conn( if self.enabled_for_logging and _CONNECTION_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _CONNECTION_LOGGER, - clientId=self._client_id, message=_ConnectionStatusMessage.CHECKOUT_FAILED, + clientId=self._client_id, serverHost=self.address[0], serverPort=self.address[1], reason="An error occurred while trying to establish a new connection", @@ -1309,8 +1309,8 @@ def checkin(self, conn: Connection) -> None: if self.enabled_for_logging and _CONNECTION_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _CONNECTION_LOGGER, - clientId=self._client_id, message=_ConnectionStatusMessage.CHECKEDIN, + clientId=self._client_id, serverHost=self.address[0], serverPort=self.address[1], driverConnectionId=conn.id, @@ -1330,8 +1330,8 @@ def checkin(self, conn: Connection) -> None: if self.enabled_for_logging and _CONNECTION_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _CONNECTION_LOGGER, - clientId=self._client_id, message=_ConnectionStatusMessage.CONN_CLOSED, + clientId=self._client_id, serverHost=self.address[0], serverPort=self.address[1], driverConnectionId=conn.id, @@ -1408,8 +1408,8 @@ def _raise_wait_queue_timeout(self, checkout_started_time: float) -> NoReturn: if self.enabled_for_logging and _CONNECTION_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _CONNECTION_LOGGER, - clientId=self._client_id, message=_ConnectionStatusMessage.CHECKOUT_FAILED, + clientId=self._client_id, serverHost=self.address[0], serverPort=self.address[1], reason="Wait queue timeout elapsed without a connection becoming available", diff --git a/pymongo/synchronous/server.py b/pymongo/synchronous/server.py index 5b8a8e3919..c3643ba815 100644 --- a/pymongo/synchronous/server.py +++ b/pymongo/synchronous/server.py @@ -108,10 +108,10 @@ def close(self) -> None: if _SDAM_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _SDAM_LOGGER, + message=_SDAMStatusMessage.STOP_SERVER, topologyId=self._topology_id, serverHost=self._description.address[0], serverPort=self._description.address[1], - message=_SDAMStatusMessage.STOP_SERVER, ) self._monitor.close() @@ -173,8 +173,8 @@ def run_operation( if _COMMAND_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _COMMAND_LOGGER, - clientId=client._topology_settings._topology_id, message=_CommandStatusMessage.STARTED, + clientId=client._topology_settings._topology_id, command=cmd, commandName=next(iter(cmd)), databaseName=dbn, @@ -234,8 +234,8 @@ def run_operation( if _COMMAND_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _COMMAND_LOGGER, - clientId=client._topology_settings._topology_id, message=_CommandStatusMessage.FAILED, + clientId=client._topology_settings._topology_id, durationMS=duration, failure=failure, commandName=next(iter(cmd)), @@ -278,8 +278,8 @@ def run_operation( if _COMMAND_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _COMMAND_LOGGER, - clientId=client._topology_settings._topology_id, message=_CommandStatusMessage.SUCCEEDED, + clientId=client._topology_settings._topology_id, durationMS=duration, reply=res, commandName=next(iter(cmd)), diff --git a/pymongo/synchronous/topology.py b/pymongo/synchronous/topology.py index bf9011830d..bccc8a2eb7 100644 --- a/pymongo/synchronous/topology.py +++ b/pymongo/synchronous/topology.py @@ -120,8 +120,8 @@ def __init__(self, topology_settings: TopologySettings): if _SDAM_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _SDAM_LOGGER, - topologyId=self._topology_id, message=_SDAMStatusMessage.START_TOPOLOGY, + topologyId=self._topology_id, ) if self._publish_tp: @@ -152,10 +152,10 @@ def __init__(self, topology_settings: TopologySettings): if _SDAM_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _SDAM_LOGGER, + message=_SDAMStatusMessage.TOPOLOGY_CHANGE, topologyId=self._topology_id, previousDescription=initial_td, newDescription=self._description, - message=_SDAMStatusMessage.TOPOLOGY_CHANGE, ) for seed in topology_settings.seeds: @@ -165,10 +165,10 @@ def __init__(self, topology_settings: TopologySettings): if _SDAM_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _SDAM_LOGGER, + message=_SDAMStatusMessage.START_SERVER, topologyId=self._topology_id, serverHost=seed[0], serverPort=seed[1], - message=_SDAMStatusMessage.START_SERVER, ) # Store the seed list to help diagnose errors in _error_message(). @@ -514,10 +514,10 @@ def _process_change( if _SDAM_LOGGER.isEnabledFor(logging.DEBUG) and not suppress_event: _debug_log( _SDAM_LOGGER, + message=_SDAMStatusMessage.TOPOLOGY_CHANGE, topologyId=self._topology_id, previousDescription=td_old, newDescription=self._description, - message=_SDAMStatusMessage.TOPOLOGY_CHANGE, ) # Shutdown SRV polling for unsupported cluster types. @@ -582,10 +582,10 @@ def _process_srv_update(self, seedlist: list[tuple[str, Any]]) -> None: if _SDAM_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _SDAM_LOGGER, + message=_SDAMStatusMessage.TOPOLOGY_CHANGE, topologyId=self._topology_id, previousDescription=td_old, newDescription=self._description, - message=_SDAMStatusMessage.TOPOLOGY_CHANGE, ) def on_srv_update(self, seedlist: list[tuple[str, Any]]) -> None: @@ -746,13 +746,13 @@ def close(self) -> None: if _SDAM_LOGGER.isEnabledFor(logging.DEBUG): _debug_log( _SDAM_LOGGER, + message=_SDAMStatusMessage.TOPOLOGY_CHANGE, topologyId=self._topology_id, previousDescription=old_td, newDescription=self._description, - message=_SDAMStatusMessage.TOPOLOGY_CHANGE, ) _debug_log( - _SDAM_LOGGER, topologyId=self._topology_id, message=_SDAMStatusMessage.STOP_TOPOLOGY + _SDAM_LOGGER, message=_SDAMStatusMessage.STOP_TOPOLOGY, topologyId=self._topology_id ) if self._publish_server or self._publish_tp: