
    *Jf                         d Z ddlZddlZddlmZmZmZmZ ddlm	Z	 ddl
mZ ddlmZ dd	lmZ er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dS )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TypeVarTYPE_CHECKING)wraps   )Self   )PGconn)connection_summary)abcFunc.)boundzpsycopg.debugc                        e Zd ZU dZded<   d 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.
abc.PGconn_pgconnpgconnc                 L    t                                          d|           d S )Nr   )super__setattr__)selfr   	__class__s     T/home/alex/cs2snipeproduction/venv/lib/python3.11/site-packages/psycopg/pq/_debug.py__init__zPGconnDebug.__init__5   s#    Iv.....    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__8   sX    *JJT^-HJJ!$,//232222RXX22222r   attrc                     t          | j        |          }t          |          rt          |          S t                              d||           |S )NzPGconn.%s -> %s)getattrr   callable	debuggingloggerr(   r   r*   values      r   __getattr__zPGconnDebug.__getattr__=   sK    d++E?? 	U###KK)4777Lr   r1   Nc                 j    t          | j        ||           t                              d||           d S )NzPGconn.%s <- %s)setattrr   r/   r(   r0   s      r   r   zPGconnDebug.__setattr__E   s3    dE***%tU33333r   conninfoc                 X     |  t          t          j                  |                    S N)r.   r   connectr'   r5   s     r   r8   zPGconnDebug.connectI   s'    s,9V^,,X66777r   c                 X     |  t          t          j                  |                    S r7   )r.   r   connect_startr9   s     r   r;   zPGconnDebug.connect_startM   s(    s29V1228<<===r   c                 F     t          t          j                  |          S r7   )r.   r   ping)r   r5   s     r   r=   zPGconnDebug.pingQ   s    %y%%h///r   )r   r   )__name__r$   r%   __doc____annotations__r   strr)   r   r2   r   classmethodbytesr	   r8   r;   intr=   __classcell__)r   s   @r   r   r   0   sA        66/ / / / / /3# 3 3 3 3
     4 4C 4D 4 4 4 4 8u 8 8 8 8 [8 >U >t > > > [> 0U 0s 0 0 0 [0 0 0 0 0r   r   fr   c                 h     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 ]}|                     |           |                                D ]\  }}|                     | d|            t                              dj        d                    |                      | i |}t          j                  j        }||t                              d|           |S )N=zPGconn.%s(%s)z, z	    <- %r)	appenditemsr/   r(   r>   joininspect	signaturereturn_annotation)	rH   rI   reprsargkvrvrarF   s	           r   
debugging_zdebugging.<locals>.debugging_Y   s     	% 	%CLLC$$$$LLNN 	' 	'DAqLLA&&&&OQZ51A1ABBBQ q!!3>R^KKR(((	r   )r   r   )rF   rX   s   ` r   r.   r.   V   sP     1XX#        X  r   )r?   rO   loggingtypingr   r   r   r   	functoolsr   _compatr	    r   miscr   r   r   	getLoggerr/   r   r.    r   r   <module>ra      s-   <   8 8 8 8 8 8 8 8 8 8 8 8                   $ $ $ $ $ $ wvXc3h/000		?	+	+#0 #0 #0 #0 #0 #0 #0 #0L $      r   