
    +h                     D   d Z ddlZddlZddlmZ ddlmZ er	dZerdndZndZdZ ej                  d	      Z	e	j                  ej                  k(  re	j                  ej                         d
 Z e       Zd Zd Z G d de      Z G d de      ZddZ G d de      Zy)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   )py311)py38T   F
sqlalchemyc                     t        j                  t        j                        }|j	                  t        j
                  d             | j                  |       y )Nz.%(asctime)s %(levelname)s %(name)s %(message)s)loggingStreamHandlersysstdoutsetFormatter	Formatter
addHandler)loggerhandlers     A/var/www/html/venv/lib/python3.12/site-packages/sqlalchemy/log.py_add_default_handlerr   ,   sC    ##CJJ/GJK g    c                 X    t        | dd       xs | j                  dz   | j                  z   S )N_sqla_logger_namespace.)getattr
__module____name__)clss    r   _qual_logger_name_for_clsr   7   s.    -t4 	/>>C#,,.r   c                     t        j                  t        |             fd| _        fd| _        | _        t        j                  |        | S )Nc                 B    j                  t        j                        S N)isEnabledForr	   DEBUGselfr   s    r   <lambda>zclass_logger.<locals>.<lambda>@   s    )<)<W]])K r   c                 B    j                  t        j                        S r   )r    r	   INFOr"   s    r   r$   zclass_logger.<locals>.<lambda>A   s    (;(;GLL(I r   )r	   	getLoggerr   _should_log_debug_should_log_infor   _logged_classesadd)r   r   s    @r   class_loggerr,   >   sC    8=>FKCICCJJr   c                       e Zd ZdZd Zd Zy)
IdentifiedNc                 T    | j                   j                  t        j                        S r   )r   r    r	   r!   r#   s    r   r(   zIdentified._should_log_debugJ   s    {{''66r   c                 T    | j                   j                  t        j                        S r   )r   r    r	   r&   r0   s    r   r)   zIdentified._should_log_infoM   s    {{''55r   )r   r   __qualname__logging_namer(   r)    r   r   r.   r.   G   s    L7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y)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                         y y y r   )echor	   r'   r   	_echo_mapr&   handlersr   )r#   r9   names      r   __init__zInstanceLogger.__init__l   sS    	''- >>$7<</8L8L - 9M/r   c                 N     | j                   t        j                  |g|i | y)z/Delegate a debug call to the underlying logger.N)logr	   r!   r#   msgargskwargss       r   r7   zInstanceLogger.debugx   s"     	5d5f5r   c                 N     | j                   t        j                  |g|i | y)z/Delegate an info call to the underlying logger.N)r?   r	   r&   r@   s       r   infozInstanceLogger.info}   s"     	s4T4V4r   c                 N     | j                   t        j                  |g|i | y)z1Delegate a warning call to the underlying logger.N)r?   r	   WARNINGr@   s       r   warningzInstanceLogger.warning   s"     	#777r   c                 N     | j                   t        j                  |g|i | y)zB
        Delegate an error call to the underlying logger.
        Nr?   r	   ERRORr@   s       r   errorzInstanceLogger.error   s"     	5d5f5r   c                 X    d|d<    | j                   t        j                  |g|i | y)z4Delegate an exception call to the underlying logger.r   exc_infoNrJ   r@   s       r   	exceptionzInstanceLogger.exception   s,     z5d5f5r   c                 N     | j                   t        j                  |g|i | y)z2Delegate a critical call to the underlying logger.N)r?   r	   CRITICALr@   s       r   criticalzInstanceLogger.critical   s$     	!!3888r   c                 f   | j                   j                  j                  |k\  ry| j                  | j                     }|t
        j                  k(  r| j                   j                         }||k\  rBt        r|j                  dd      t        z   |d<    | j                   j                  |||fi | yy)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
stacklevelr   )r   managerdisabler:   r9   r	   NOTSETgetEffectiveLevel
STACKLEVELgetSTACKLEVEL_OFFSET_log)r#   levelrA   rB   rC   selected_levels         r   r?   zInstanceLogger.log   s     ;;&&%/		2W^^+![[::<NN"JJ|Q/2CC |$ DKKUC88 #r   c                 p    | j                   j                  j                  |k\  ry|| j                         k\  S )z)Is this logger enabled for level 'level'?F)r   rU   rV   rX   r#   r]   s     r   r    zInstanceLogger.isEnabledFor   s3     ;;&&%/..000r   c                     | j                   | j                     }|t        j                  k(  r| j                  j                         }|S )z+What's the effective level for this logger?)r:   r9   r	   rW   r   rX   r`   s     r   rX   z InstanceLogger.getEffectiveLevel   s9     tyy)GNN"KK113Er   N)r   r   r2   __doc__r	   rW   r&   r!   r:   r=   r7   rE   rH   warnrL   rO   rR   r?   r    rX   r4   r   r   r6   r6   Q   se    ( nn~~ll	I.6
5
8
 D669
961r   r6   c                    | j                   r%t        | j                        d| j                   }nt        | j                        }|| _        |dv rt	        j
                  |      }|| _        yt        ||      }|| _        y)zEcreate a logger for an instance that implements :class:`.Identified`.r   )FNN)r3   r   	__class___echor	   r'   r6   r   )instanceechoflagr<   r   s       r   instance_loggerri      s|     %h&8&89!!

 )););<HN=  ""4( HO  $/HOr   c                       e Zd ZdZd Zd Zy)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   )rf   )r#   rg   owners      r   __get__zecho_property.__get__   s    K>>!r   c                     t        ||       y )N)rh   )ri   )r#   rg   values      r   __set__zecho_property.__set__   s    51r   N)r   r   r2   rb   rn   rq   r4   r   r   rk   rk      s    G"2r   rk   r   )rb   r	   r   utilr   r   rY   r[   r'   
rootloggerr]   rW   setLevelWARNr   setr*   r   r,   objectr.   r6   ri   rk   r4   r   r   <module>rx      s   
  
  J #J
 W|,
w~~%% %6 6qV qh42F 2r   