event_loggers – Example loggers - PyMongo 4.13.2 documentation (original) (raw)
Toggle table of contents sidebar
Example event logger classes.
Added in version 3.11.
These loggers can be registered using register()
orMongoClient.
monitoring.register(CommandLogger())
or
MongoClient(event_listeners=[CommandLogger()])
See also
This module is compatible with both the synchronous and asynchronous PyMongo APIs.
class pymongo.event_loggers.CommandLogger¶
A simple listener that logs command events.
Listens for CommandStartedEvent,CommandSucceededEvent andCommandFailedEvent events and logs them at the INFO severity level using logging. .. versionadded:: 3.11
failed(event)¶
Abstract method to handle a CommandFailedEvent.
Parameters:
event (CommandFailedEvent) – An instance of CommandFailedEvent
.
Return type:
None
started(event)¶
Abstract method to handle a CommandStartedEvent.
Parameters:
event (CommandStartedEvent) – An instance of CommandStartedEvent
.
Return type:
None
succeeded(event)¶
Abstract method to handle a CommandSucceededEvent.
Parameters:
event (CommandSucceededEvent) – An instance of CommandSucceededEvent
.
Return type:
None
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 ConnectionCheckedInEventevents and logs them at the INFO severity level using logging.
Added 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 (ConnectionCheckOutFailedEvent) – An instance of ConnectionCheckOutFailedEvent
.
Return type:
None
connection_check_out_started(event)¶
Abstract method to handle a ConnectionCheckOutStartedEvent
.
Emitted when the driver starts attempting to check out a connection.
Parameters:
event (ConnectionCheckOutStartedEvent) – An instance of ConnectionCheckOutStartedEvent
.
Return type:
None
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 (ConnectionCheckedInEvent) – An instance of ConnectionCheckedInEvent
.
Return type:
None
connection_checked_out(event)¶
Abstract method to handle a ConnectionCheckedOutEvent
.
Emitted when the driver successfully checks out a connection.
Parameters:
event (ConnectionCheckedOutEvent) – An instance of ConnectionCheckedOutEvent
.
Return type:
None
connection_closed(event)¶
Abstract method to handle a ConnectionClosedEvent
.
Emitted when a connection Pool closes a connection.
Parameters:
event (ConnectionClosedEvent) – An instance of ConnectionClosedEvent
.
Return type:
None
connection_created(event)¶
Abstract method to handle a ConnectionCreatedEvent
.
Emitted when a connection Pool creates a Connection object.
Parameters:
event (ConnectionCreatedEvent) – An instance of ConnectionCreatedEvent
.
Return type:
None
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 (ConnectionReadyEvent) – An instance of ConnectionReadyEvent
.
Return type:
None
pool_cleared(event)¶
Abstract method to handle a PoolClearedEvent.
Emitted when a connection Pool is cleared.
Parameters:
event (PoolClearedEvent) – An instance of PoolClearedEvent
.
Return type:
None
pool_closed(event)¶
Abstract method to handle a PoolClosedEvent.
Emitted when a connection Pool is closed.
Parameters:
event (PoolClosedEvent) – An instance of PoolClosedEvent
.
Return type:
None
pool_created(event)¶
Abstract method to handle a PoolCreatedEvent
.
Emitted when a connection Pool is created.
Parameters:
event (PoolCreatedEvent) – An instance of PoolCreatedEvent
.
Return type:
None
pool_ready(event)¶
Abstract method to handle a PoolReadyEvent
.
Emitted when a connection Pool is marked ready.
Parameters:
event (PoolReadyEvent) – An instance of PoolReadyEvent
.
Return type:
None
Added in version 4.0.
class pymongo.event_loggers.HeartbeatLogger¶
A simple listener that logs server heartbeat events.
Listens for ServerHeartbeatStartedEvent,ServerHeartbeatSucceededEvent, and ServerHeartbeatFailedEventevents and logs them at the INFO severity level using logging.
Added in version 3.11.
failed(event)¶
Abstract method to handle a ServerHeartbeatFailedEvent.
Parameters:
event (ServerHeartbeatFailedEvent) – An instance of ServerHeartbeatFailedEvent
.
Return type:
None
started(event)¶
Abstract method to handle a ServerHeartbeatStartedEvent.
Parameters:
event (ServerHeartbeatStartedEvent) – An instance of ServerHeartbeatStartedEvent
.
Return type:
None
succeeded(event)¶
Abstract method to handle a ServerHeartbeatSucceededEvent.
Parameters:
event (ServerHeartbeatSucceededEvent) – An instance of ServerHeartbeatSucceededEvent
.
Return type:
None
class pymongo.event_loggers.ServerLogger¶
A simple listener that logs server discovery events.
Listens for ServerOpeningEvent,ServerDescriptionChangedEvent, and ServerClosedEventevents and logs them at the INFO severity level using logging.
Added in version 3.11.
closed(event)¶
Abstract method to handle a ServerClosedEvent.
Parameters:
event (ServerClosedEvent) – An instance of ServerClosedEvent
.
Return type:
None
description_changed(event)¶
Abstract method to handle a ServerDescriptionChangedEvent.
Parameters:
event (ServerDescriptionChangedEvent) – An instance of ServerDescriptionChangedEvent
.
Return type:
None
opened(event)¶
Abstract method to handle a ServerOpeningEvent.
Parameters:
event (ServerOpeningEvent) – An instance of ServerOpeningEvent
.
Return type:
None
class pymongo.event_loggers.TopologyLogger¶
A simple listener that logs server topology events.
Listens for TopologyOpenedEvent,TopologyDescriptionChangedEvent, and TopologyClosedEventevents and logs them at the INFO severity level using logging.
Added in version 3.11.
closed(event)¶
Abstract method to handle a TopologyClosedEvent.
Parameters:
event (TopologyClosedEvent) – An instance of TopologyClosedEvent
.
Return type:
None
description_changed(event)¶
Abstract method to handle a TopologyDescriptionChangedEvent.
Parameters:
event (TopologyDescriptionChangedEvent) – An instance of TopologyDescriptionChangedEvent
.
Return type:
None
opened(event)¶
Abstract method to handle a TopologyOpenedEvent.
Parameters:
event (TopologyOpenedEvent) – An instance of TopologyOpenedEvent
.
Return type:
None