
    ؄_1                     
   d Z ddlZddlZ ej        d          Zej        ej        k    re                    ej                   d Z	 e
            Zd Z G d de          Z G d d	e          Zdd
Z G d de          ZdS )a  Logging control and utilities.

Control of logging for SA can be performed from the regular python logging
module.  The regular dotted module namespace is used, starting at
'sqlalchemy'.  For class-level logging, the class name is appended.

The "echo" keyword parameter, available on SQLA :class:`_engine.Engine`
and :class:`_pool.Pool` objects, corresponds to a logger specific to that
instance only.

    N
sqlalchemyc                     t          j        t          j                  }|                    t          j        d                     |                     |           d S )Nz.%(asctime)s %(levelname)s %(name)s %(message)s)loggingStreamHandlersysstdoutsetFormatter	Formatter
addHandler)loggerhandlers     S/var/www/book.euthymeo.com/html/venv/lib/python3.11/site-packages/sqlalchemy/log.py_add_default_handlerr   !   sW    #CJ//GJKK   g    c                     t          j        | j        dz   | j        z             fd| _        fd| _        | _        t                              |            | S )N.c                 B                         t          j                  S N)isEnabledForr   DEBUGselfr   s    r   <lambda>zclass_logger.<locals>.<lambda>.   s    )<)<W])K)K r   c                 B                         t          j                  S r   )r   r   INFOr   s    r   r   zclass_logger.<locals>.<lambda>/   s    (;(;GL(I(I r   )	r   	getLogger
__module____name___should_log_debug_should_log_infor   _logged_classesadd)clsr   s    @r   class_loggerr$   ,   sc    s~3clBCCFKKKKCIIIICCJJr   c                       e Zd ZdZd Zd ZdS )
IdentifiedNc                 J    | j                             t          j                  S r   )r   r   r   r   r   s    r   r   zIdentified._should_log_debug8   s    {''666r   c                 J    | j                             t          j                  S r   )r   r   r   r   r(   s    r   r    zIdentified._should_log_info;   s    {''555r   )r   r   __qualname__logging_namer   r     r   r   r&   r&   5   s7        L7 7 76 6 6 6 6r   r&   c                       e Zd ZdZej        ej        ej        ej        dZd Z	d Z
d Zd ZeZd Zd Zd	 Zd
 Zd Zd ZdS )InstanceLoggera  A logger adapter (wrapper) for :class:`.Identified` subclasses.

    This allows multiple instances (e.g. Engine or Pool instances)
    to share a logger, but have its verbosity controlled on a
    per-instance basis.

    The basic functionality is to return a logging level
    which is based on an instance's echo setting.

    Default implementation is:

    'debug' -> logging.DEBUG
    True    -> logging.INFO
    False   -> Effective level of underlying logger (
    logging.WARNING by default)
    None    -> same as False
    )NFTdebugc                     || _         t          j        |          | _        | j        |         t          j        k    r"| j        j        st          | j                   d S d S d S r   )echor   r   r   	_echo_mapr   handlersr   )r   r1   names      r   __init__zInstanceLogger.__init__Z   s_    	'-- >$7<//8L/ ----- 0///r   c                 >     | j         t          j        |g|R i | dS )z/Delegate a debug call to the underlying logger.N)logr   r   r   msgargskwargss       r   r/   zInstanceLogger.debugf   s0     	5d555f55555r   c                 >     | j         t          j        |g|R i | dS )z/Delegate an info call to the underlying logger.N)r7   r   r   r8   s       r   infozInstanceLogger.infok   s0     	s4T444V44444r   c                 >     | j         t          j        |g|R i | dS )z1Delegate a warning call to the underlying logger.N)r7   r   WARNINGr8   s       r   warningzInstanceLogger.warningp   s0     	#777777777r   c                 >     | j         t          j        |g|R i | dS )zB
        Delegate an error call to the underlying logger.
        Nr7   r   ERRORr8   s       r   errorzInstanceLogger.errorw   s0     	5d555f55555r   c                 H    d|d<    | j         t          j        |g|R i | dS )z4Delegate an exception call to the underlying logger.   exc_infoNrB   r8   s       r   	exceptionzInstanceLogger.exception}   s:     z5d555f55555r   c                 >     | j         t          j        |g|R i | dS )z2Delegate a critical call to the underlying logger.N)r7   r   CRITICALr8   s       r   criticalzInstanceLogger.critical   s1     	!3888888888r   c                     | j         j        j        |k    rdS | j        | j                 }|t
          j        k    r| j                                         }||k    r | j         j        |||fi | dS dS )zDelegate a log call to the underlying logger.

        The level here is determined by the echo
        flag as well as that of the underlying logger, and
        logger._log() is called directly.

        N)	r   managerdisabler2   r1   r   NOTSETgetEffectiveLevel_log)r   levelr9   r:   r;   selected_levels         r   r7   zInstanceLogger.log   s     ;&%//F	2W^++![::<<NN""DKUC8888888 #"r   c                 `    | j         j        j        |k    rdS ||                                 k    S )z)Is this logger enabled for level 'level'?F)r   rM   rN   rP   r   rR   s     r   r   zInstanceLogger.isEnabledFor   s3     ;&%//5..0000r   c                 |    | j         | j                 }|t          j        k    r| j                                        }|S )z+What's the effective level for this logger?)r2   r1   r   rO   r   rP   rU   s     r   rP   z InstanceLogger.getEffectiveLevel   s7     ty)GN""K1133Er   N)r   r   r*   __doc__r   rO   r   r   r2   r5   r/   r=   r@   warnrD   rH   rK   r7   r   rP   r,   r   r   r.   r.   ?   s         ( n~l	 I. . .6 6 6
5 5 5
8 8 8
 D6 6 66 6 69 9 9
9 9 9,1 1 1    r   r.   c                     | j         r$| j        j        d| j        j        d| j         }n| j        j        d| j        j        }|| _        |dv rt          j        |          }nt          ||          }|| _        dS )zEcreate a logger for an instance that implements :class:`.Identified`.r   )FNN)	r+   	__class__r   r   _echor   r   r.   r   )instanceechoflagr4   r   s       r   instance_loggerr^      s      

)))'''!!
 )))''

 HN=   "4((
  $//HOOOr   c                       e Zd ZdZd Zd ZdS )echo_propertya}      When ``True``, enable log output for this element.

    This has the effect of setting the Python logging level for the namespace
    of this element's class and object reference.  A value of boolean ``True``
    indicates that the loglevel ``logging.INFO`` will be set for the logger,
    whereas the string value ``debug`` will set the loglevel to
    ``logging.DEBUG``.
    c                     || S |j         S r   )r[   )r   r\   owners      r   __get__zecho_property.__get__   s    K>!r   c                 (    t          ||           d S )N)r]   )r^   )r   r\   values      r   __set__zecho_property.__set__   s    5111111r   N)r   r   r*   rW   rc   rf   r,   r   r   r`   r`      s9        G" " "2 2 2 2 2r   r`   r   )rW   r   r   r   
rootloggerrR   rO   setLevelWARNr   setr!   r$   objectr&   r.   r^   r`   r,   r   r   <module>rl      s-  
 
  



 W|,,
w~%%%%%   #%%  6 6 6 6 6 6 6 6l l l l lV l l l^   <2 2 2 2 2F 2 2 2 2 2r   