event_loggers
– Example loggers
New in version 3.11.
These loggers can be registered using register()
or MongoClient.
monitoring.register(CommandLogger())
or
MongoClient(event_listeners=[CommandLogger()])
class pymongo.event_loggers.CommandLogger
A simple listener that logs command events.
Listens for , CommandSucceededEvent and events and logs them at the INFO severity level using logging. .. versionadded:: 3.11
failed
(event)Abstract method to handle a CommandFailedEvent.
started
(event)Abstract method to handle a CommandStartedEvent.
Parameters: - event: An instance of
CommandStartedEvent
.
- event: An instance of
succeeded
(event)Abstract method to handle a CommandSucceededEvent.
Parameters: - event: An instance of
CommandSucceededEvent
.
- event: An instance of
class pymongo.event_loggers.ConnectionPoolLogger
A simple listener that logs server connection pool events.
Listens for , PoolClearedEvent, , :~pymongo.monitoring.class:ConnectionCreatedEvent, ConnectionReadyEvent, , ConnectionCheckOutStartedEvent, , ConnectionCheckedOutEvent, and events and logs them at the INFO severity level using logging.
New in version 3.11.
connection_check_out_failed
(event)Abstract method to handle a
ConnectionCheckOutFailedEvent
.Emitted when the driver’s attempt to check out a connection fails.
Parameters: - event: An instance of
ConnectionCheckOutFailedEvent
.
- event: An instance of
connection_check_out_started
(event)Abstract method to handle a
ConnectionCheckOutStartedEvent
.Emitted when the driver starts attempting to check out a connection.
Parameters: - event: An instance of
ConnectionCheckOutStartedEvent
.
- event: An instance of
connection_checked_in
(event)Emitted when the driver checks in a Connection back to the Connection Pool.
Parameters: - event: An instance of
ConnectionCheckedInEvent
.
- event: An instance of
connection_checked_out
(event)Abstract method to handle a
ConnectionCheckedOutEvent
.Emitted when the driver successfully checks out a Connection.
Parameters: - event: An instance of
ConnectionCheckedOutEvent
.
- event: An instance of
connection_created
(event)Abstract method to handle a
ConnectionCreatedEvent
.Emitted when a Connection Pool creates a Connection object.
connection_ready
(event)Abstract method to handle a
ConnectionReadyEvent
.Emitted when a Connection has finished its setup, and is now ready to use.
Parameters: - event: An instance of
ConnectionReadyEvent
.
- event: An instance of
pool_cleared
(event)Abstract method to handle a PoolClearedEvent.
Emitted when a Connection Pool is cleared.
Parameters: - event: An instance of
PoolClearedEvent
.
- event: An instance of
pool_closed
(event)Abstract method to handle a PoolClosedEvent.
Emitted when a Connection Pool is closed.
Parameters: - event: An instance of
PoolClosedEvent
.
- event: An instance of
pool_created
(event)Abstract method to handle a
PoolCreatedEvent
.Emitted when a Connection Pool is created.
Parameters: - event: An instance of .
class pymongo.event_loggers.HeartbeatLogger
A simple listener that logs server heartbeat events.
Listens for , ServerHeartbeatSucceededEvent, and events and logs them at the INFO severity level using logging.
failed
(event)Abstract method to handle a ServerHeartbeatFailedEvent.
Parameters: - event: An instance of
ServerHeartbeatFailedEvent
.
- event: An instance of
started
(event)Abstract method to handle a ServerHeartbeatStartedEvent.
Parameters: succeeded
(event)Abstract method to handle a ServerHeartbeatSucceededEvent.
class pymongo.event_loggers.ServerLogger
A simple listener that logs server discovery events.
Listens for , ServerDescriptionChangedEvent, and events and logs them at the INFO severity level using logging.
New in version 3.11.
closed
(event)Abstract method to handle a ServerClosedEvent.
Parameters: - event: An instance of
ServerClosedEvent
.
- event: An instance of
description_changed
(event)Abstract method to handle a ServerDescriptionChangedEvent.
Parameters: - event: An instance of
ServerDescriptionChangedEvent
.
- event: An instance of
opened
(event)Abstract method to handle a ServerOpeningEvent.
Parameters: - event: An instance of
ServerOpeningEvent
.
- event: An instance of
class pymongo.event_loggers.TopologyLogger
A simple listener that logs server topology events.
Listens for , TopologyDescriptionChangedEvent, and events and logs them at the INFO severity level using logging.
New in version 3.11.
closed
(event)Abstract method to handle a TopologyClosedEvent.
Parameters: - event: An instance of
TopologyClosedEvent
.
- event: An instance of
description_changed
(event)Abstract method to handle a TopologyDescriptionChangedEvent.
Parameters: - event: An instance of
TopologyDescriptionChangedEvent
.
- event: An instance of
(event)
Parameters: - event: An instance of
TopologyOpenedEvent
.
- event: An instance of