Ë
    Ûq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 dd
l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é   )ÚSelfÚTypeVaré   )Úabc)ÚPGconn)Úconnection_summaryÚ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     €úR/var/www/html/kelly-backend/venv/lib/python3.12/site-packages/psycopg/pq/_debug.pyÚ__init__zPGconnDebug.__init__3   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__6   sW   € Ø—‘×*Ñ*Ð+¨1¨T¯^©^×-HÑ-HÐ,IÐJˆÜ! $§,¡,Ó/ˆØ�3�%�q˜˜˜f¤R¨£X¨a L°Ð2Ð2r   Úattrc                 óŒ   — t        | j                  |«      }t        |«      rt        |«      S t        j                  d||«       |S )NzPGconn.%s -> %s)Úgetattrr   ÚcallableÚ	debuggingÚloggerr&   ©r   r(   Úvalues      r   Ú__getattr__zPGconnDebug.__getattr__;   s:   € Ü˜Ÿ™ dÓ+ˆÜ�EŒ?Ü˜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__C   s#   € Ü�—‘˜d EÔ*Ü�‰Ð% t¨UÕ3r   Úconninfoc                 óL   —  |  t        t        j                  «      |«      «      S ©N)r,   r   Úconnect©r%   r3   s     r   r6   zPGconnDebug.connectG   s   € áÐ,”9œVŸ^™^Ó,¨XÓ6Ó7Ð7r   c                 óL   —  |  t        t        j                  «      |«      «      S r5   )r,   r   Úconnect_startr7   s     r   r9   zPGconnDebug.connect_startK   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.pingO   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 )NÚ=zPGconn.%s(%s)z, z	    <- %r)	ÚappendÚitemsr-   r&   r<   ÚjoinÚinspectÚ	signatureÚreturn_annotation)	rF   rG   ÚreprsÚargÚkÚvÚrvÚrarD   s	           €r   Ú
debugging_zdebugging.<locals>.debugging_W   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Ù�Ð˜Ñˆô ×Ñ˜qÓ!×3Ñ3ˆØˆ>˜R˜^Ü�K‰K˜ RÔ(Øˆ	r   )r   r   )rD   rV   s   ` r   r,   r,   T   s8   ø€ ô ˆ1ƒXðœ#ð ¬ð ´ô ó ðð  Ðr   )r=   rM   ÚloggingÚtypingr   r   Ú	functoolsr   Ú_compatr   r   Ú r
   r   Úmiscr   r   Ú	getLoggerr-   r   r,   © r   r   Ú<module>r_      si   ðñó< Û ß  Ý ß #å Ý Ý $áˆv˜X c¨3 hÑ/Ô0€à	ˆ×	Ñ	˜?Ó	+€÷#0ñ #0ðL�ð ˜$ô r   