Ë
    êëj  ã                   óÆ   — d Z ddlZddlZddlmZmZ ddlmZ ddlm	Z	m
Z
 ddlmZ dd	lmZmZ  ed
edef   ¬«      Z ej"                  d«      Z G d„ d«      Zdedefd„Zy)a²  
libpq debugging tools

These functionalities are exposed here for convenience, but are not part of
the public interface and are subject to change at any moment.

Suggested usage::

    import logging
    import psycopg
    from psycopg import pq
    from psycopg.pq._debug import PGconnDebug

    logging.basicConfig(level=logging.INFO, format="%(message)s")
    logger = logging.getLogger("psycopg.debug")
    logger.setLevel(logging.INFO)

    assert pq.__impl__ == "python"
    pq.PGconn = PGconnDebug

    with psycopg.connect("") as conn:
        conn.pgconn.trace(2)
        conn.pgconn.set_trace_flags(
            pq.Trace.SUPPRESS_TIMESTAMPS | pq.Trace.REGRESS_MODE)
        ...

é    N)ÚAnyÚCallable)Úwrapsé   )ÚPGconnÚabc)Úconnection_summaryé   )ÚSelfÚTypeVarÚFunc.)Úboundzpsycopg.debugc                   óÚ   ‡ — e Zd ZU dZej
                  ed<   dej
                  fˆ fd„Zdefd„Z	dede
fd„Zded	e
dd
fd„Zededefd„«       Zededefd„«       Zededefd„«       Zˆ xZS )ÚPGconnDebugz,Wrapper for a PQconn logging all its access.Ú_pgconnÚpgconnc                 ó&   •— t         ‰| �  d|«       y )Nr   )ÚsuperÚ__setattr__)Úselfr   Ú	__class__s     €úX/var/www/html/kelly/kelly-backend/venv/lib/python3.12/site-packages/psycopg/pq/_debug.pyÚ__init__zPGconnDebug.__init__2   s   ø€ Ü‰Ñ˜I vÕ.ó    Úreturnc                 ó¶   — | j                   j                  › d| j                   j                  › �}t        | j                  «      }d|› d|› dt        | «      d›d�S )NÚ.Ú<Ú z at 0xÚxÚ>)r   Ú
__module__Ú__qualname__r	   r   Úid)r   ÚclsÚinfos      r   Ú__repr__zPGconnDebug.__repr__5   sW   € Ø—‘×*Ñ*Ð+¨1¨T¯^©^×-HÑ-HÐ,IÐJˆÜ! $§,¡,Ó/ˆØ�3�%�q˜˜˜f¤R¨£X¨a L°Ð2Ð2r   Úattrc                 óŒ   — t        t        | j                  |«      x}«      rt        |«      S t        j                  d||«       |S )NzPGconn.%s -> %s)ÚcallableÚgetattrr   Ú	debuggingÚloggerr&   ©r   r(   Úvalues      r   Ú__getattr__zPGconnDebug.__getattr__:   s;   € Üœg d§l¡l°DÓ9Ð9�UÔ;Ü˜UÓ#Ð#ä�K‰KÐ)¨4°Ô7ØˆLr   r/   Nc                 ó`   — t        | j                  ||«       t        j                  d||«       y )NzPGconn.%s <- %s)Úsetattrr   r-   r&   r.   s      r   r   zPGconnDebug.__setattr__A   s#   € Ü�—‘˜d EÔ*Ü�‰Ð% t¨UÕ3r   Úconninfoc                 óL   —  |  t        t        j                  «      |«      «      S ©N)r,   r   Úconnect©r%   r3   s     r   r6   zPGconnDebug.connectE   s   € áÐ,”9œVŸ^™^Ó,¨XÓ6Ó7Ð7r   c                 óL   —  |  t        t        j                  «      |«      «      S r5   )r,   r   Úconnect_startr7   s     r   r9   zPGconnDebug.connect_startI   s    € áÐ2”9œV×1Ñ1Ó2°8Ó<Ó=Ð=r   c                 ó@   —  t        t        j                  «      |«      S r5   )r,   r   Úping)r   r3   s     r   r;   zPGconnDebug.pingM   s   € à%ŒyœŸ™Ó% hÓ/Ð/r   )Ú__name__r"   r#   Ú__doc__r   r   Ú__annotations__r   Ústrr'   r   r0   r   ÚclassmethodÚbytesr   r6   r9   Úintr;   Ú__classcell__)r   s   @r   r   r   -   s¿   ø… Ù6à�Z‰ZÓð/˜sŸz™zõ /ð3˜#ó 3ð
 ð ¨ó ð4 ð 4¨Cð 4°Dó 4ð ð8˜uð 8¨ò 8ó ð8ð ð> Uð >¨tò >ó ð>ð ð0˜Uð 0 sò 0ó ô0r   r   Úfr   c                 óT   ‡ — t        ‰ «      dt        dt        dt        fˆ fd„«       }|S )zGWrap a function in order to log its arguments and return value on call.ÚargsÚkwargsr   c                  óÎ  •— g }| D ]  }|j                  |›«       Œ |j                  «       D ]  \  }}|j                  |› d|›�«       Œ t        j                  d‰	j                  dj                  |«      «       	  ‰	| i |¤Ž}t        j                  ‰	«      j                  }|€|�t        j                  d|«       |S # t        $ r}t        j                  d|«       ‚ d }~ww xY w)NÚ=zPGconn.%s(%s)z, z	    <- %r)
ÚappendÚitemsr-   r&   r<   ÚjoinÚinspectÚ	signatureÚreturn_annotationÚ	Exception)
rF   rG   ÚreprsÚargÚkÚvÚrvÚraÚexrD   s
            €r   Ú
debugging_zdebugging.<locals>.debugging_U   sÔ   ø€ àˆÛˆCØ�L‰L˜C˜7Õ$ð à—L‘L–N‰DˆAˆqØ�L‰L˜A˜3˜a ˜u˜Õ&ð #ô 	�‰�O Q§Z¡Z°·±¸5Ó1AÔBð	Ù�DÐ#˜FÑ#ˆBô ×"Ñ" 1Ó%×7Ñ7ˆBØˆ~  Ü—‘˜K¨Ô,ØˆIøô ò 	Ü�K‰K˜ RÔ(Øûð	ús   Á<B? Â?	C$ÃCÃC$)r   r   )rD   rX   s   ` r   r,   r,   R   s8   ø€ ô ˆ1ƒXðœ#ð ¬ð ´ô ó ðð* Ðr   )r=   rM   ÚloggingÚtypingr   r   Ú	functoolsr   Ú r   r   Úmiscr	   Ú_compatr   r   r   Ú	getLoggerr-   r   r,   © r   r   Ú<module>ra      sf   ðñó< Û ß  Ý ç Ý $ß #áˆv˜X c¨3 hÑ/Ô0€à	ˆ×	Ñ	˜?Ó	+€÷"0ñ "0ðJ�ð ˜$ô r   