
    | f                         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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)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                 L    t                                          d|           d S )Nr   )super__setattr__)selfr   	__class__s     G/var/www/equiseq/venv/lib/python3.11/site-packages/psycopg/pq/_debug.py__init__zPGconnDebug.__init__3   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__6   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   r/   Nc                 j    t          | j        ||           t                              d||           d S )NzPGconn.%s <- %s)setattrr   r-   r&   r.   s      r   r   zPGconnDebug.__setattr__C   s3    dE***%tU33333r   conninfoc                 X     |  t          t          j                  |                    S N)r,   r   connectr%   r3   s     r   r6   zPGconnDebug.connectG   s'    s,9V^,,X66777r   c                 X     |  t          t          j                  |                    S r5   )r,   r   connect_startr7   s     r   r9   zPGconnDebug.connect_startK   s(    s29V1228<<===r   c                 F     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   .   sL        66Z/sz / / / / / /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)	rF   rG   reprsargkvrvrarD   s	           r   
debugging_zdebugging.<locals>.debugging_W   s     	% 	%CLLC$$$$LLNN 	' 	'DAqLLA&&&&OQZ51A1ABBBQ q!!3>R^KKR(((	r   )r   r   )rD   rV   s   ` r   r,   r,   T   sP     1XX#        X  r   )r=   rM   loggingtypingr   r   	functoolsr   _compatr   r    r
   r   miscr   r   	getLoggerr-   r   r,    r   r   <module>r_      s   <                         # # # # # # # #             $ $ $ $ $ $wvXc3h/000		?	+	+#0 #0 #0 #0 #0 #0 #0 #0L $      r   