event_loggers
– Example loggers
Example event logger classes.
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 CommandStartedEvent, CommandSucceededEvent and CommandFailedEvent events and logs them at the INFO severity level using logging. .. versionadded:: 3.11
failed
(event)Abstract method to handle a CommandFailedEvent.
Parameters: - event: An instance of
CommandFailedEvent
.
- event: An instance of
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 PoolCreatedEvent, PoolClearedEvent, PoolClosedEvent, :~pymongo.monitoring.class:ConnectionCreatedEvent, ConnectionReadyEvent, ConnectionClosedEvent, ConnectionCheckOutStartedEvent, ConnectionCheckOutFailedEvent, ConnectionCheckedOutEvent, and ConnectionCheckedInEvent 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)Abstract method to handle a
ConnectionCheckedInEvent
.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_closed
(event)Abstract method to handle a
ConnectionClosedEvent
.Emitted when a Connection Pool closes a Connection.
Parameters: - event: An instance of
ConnectionClosedEvent
.
- event: An instance of
connection_created
(event)Abstract method to handle a
ConnectionCreatedEvent
.Emitted when a Connection Pool creates a Connection object.
Parameters: - event: An instance of
ConnectionCreatedEvent
.
- event: An instance of
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
PoolCreatedEvent
.
- event: An instance of
class pymongo.event_loggers.HeartbeatLogger
A simple listener that logs server heartbeat events.
Listens for ServerHeartbeatStartedEvent, ServerHeartbeatSucceededEvent, and ServerHeartbeatFailedEvent events and logs them at the INFO severity level using logging.
New in version 3.11.
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: - event: An instance of
ServerHeartbeatStartedEvent
.
- event: An instance of
succeeded
(event)Abstract method to handle a ServerHeartbeatSucceededEvent.
Parameters: - event: An instance of
ServerHeartbeatSucceededEvent
.
- event: An instance of
class pymongo.event_loggers.ServerLogger
A simple listener that logs server discovery events.
Listens for ServerOpeningEvent, ServerDescriptionChangedEvent, and ServerClosedEvent 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 TopologyOpenedEvent, TopologyDescriptionChangedEvent, and TopologyClosedEvent 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
opened
(event)Abstract method to handle a TopologyOpenedEvent.
Parameters: - event: An instance of
TopologyOpenedEvent
.
- event: An instance of