o Sbf#@svdZddlZddlmZGdddejZGdddejZGdd d ejZ Gd d d ej Z Gd d d ej Z dS)zExample event logger classes. .. versionadded:: 3.11 These loggers can be registered using :func:`register` or :class:`~pymongo.mongo_client.MongoClient`. ``monitoring.register(CommandLogger())`` or ``MongoClient(event_listeners=[CommandLogger()])`` N) monitoringc@LeZdZdZdejddfddZdejddfddZdej ddfd d Z dS) CommandLoggeraIA simple listener that logs command events. Listens for :class:`~pymongo.monitoring.CommandStartedEvent`, :class:`~pymongo.monitoring.CommandSucceededEvent` and :class:`~pymongo.monitoring.CommandFailedEvent` events and logs them at the `INFO` severity level using :mod:`logging`. .. versionadded:: 3.11 eventreturnNcCs&td|jd|jd|jdS)NCommand  with request id z started on server )logginginfo command_name request_id connection_idselfrrtddSdS)Nz-Topology description updated for topology id z Topology r%r&zNo writable servers available.zNo readable servers available.) r r r"r'Z topology_typer(Ztopology_type_nameZhas_writable_serverr*Zhas_readable_server)rrZprevious_topology_typeZnew_topology_typerrrr)s     z"TopologyLogger.description_changedcCr0)Nr1z closedr2rrrrr+r3zTopologyLogger.closed) rrrrrZTopologyOpenedEventr#ZTopologyDescriptionChangedEventr)ZTopologyClosedEventr+rrrrr/}s  r/c@seZdZdZdejddfddZddZdejddfd d Z dej ddfd d Z dej ddfd dZ dejddfddZdejddfddZdejddfddZdejddfddZdejddfddZdejddfddZdS)ConnectionPoolLoggeraA simple listener that logs server connection pool events. Listens for :class:`~pymongo.monitoring.PoolCreatedEvent`, :class:`~pymongo.monitoring.PoolClearedEvent`, :class:`~pymongo.monitoring.PoolClosedEvent`, :~pymongo.monitoring.class:`ConnectionCreatedEvent`, :class:`~pymongo.monitoring.ConnectionReadyEvent`, :class:`~pymongo.monitoring.ConnectionClosedEvent`, :class:`~pymongo.monitoring.ConnectionCheckOutStartedEvent`, :class:`~pymongo.monitoring.ConnectionCheckOutFailedEvent`, :class:`~pymongo.monitoring.ConnectionCheckedOutEvent`, and :class:`~pymongo.monitoring.ConnectionCheckedInEvent` events and logs them at the `INFO` severity level using :mod:`logging`. .. versionadded:: 3.11 rrNcCr0)N[pool z] pool createdr r addressrrrr pool_createdr3z!ConnectionPoolLogger.pool_createdcCr0)Nr5z ] pool readyr6rrrr pool_readyr3zConnectionPoolLogger.pool_readycCr0)Nr5z] pool clearedr6rrrr pool_clearedr3z!ConnectionPoolLogger.pool_clearedcCr0)Nr5z ] pool closedr6rrrr pool_closedr3z ConnectionPoolLogger.pool_closedcC td|jd|jddS)Nr5][conn #z] connection createdr r r7r rrrrconnection_createds z'ConnectionPoolLogger.connection_createdcCr<)Nr5r=z] connection setup succeededr>rrrrconnection_readyz%ConnectionPoolLogger.connection_readyc Cs(td|jd|jd|jddS)Nr5r=z] connection closed, reason: "")r r r7r reasonrrrrconnection_closeds z&ConnectionPoolLogger.connection_closedcCr0)Nr5z] connection check out startedr6rrrrconnection_check_out_startedsz1ConnectionPoolLogger.connection_check_out_startedcCr)Nr5z'] connection check out failed, reason: )r r r7rCrrrrconnection_check_out_failedr$z0ConnectionPoolLogger.connection_check_out_failedcCr<)Nr5r=z ] connection checked out of poolr>rrrrconnection_checked_outrAz+ConnectionPoolLogger.connection_checked_outcCr<)Nr5r=z] connection checked into poolr>rrrrconnection_checked_inrAz*ConnectionPoolLogger.connection_checked_in)rrrrrZPoolCreatedEventr8r9ZPoolClearedEventr:ZPoolClosedEventr;ZConnectionCreatedEventr?ZConnectionReadyEventr@ZConnectionClosedEventrDZConnectionCheckOutStartedEventrEZConnectionCheckOutFailedEventrFZConnectionCheckedOutEventrGZConnectionCheckedInEventrHrrrrr4s" r4)rr ZpymongorZCommandListenerrZServerListenerrZServerHeartbeatListenerr,ZTopologyListenerr/ZConnectionPoolListenerr4rrrrs "$