
    [h!                       U d Z ddlmZ ddlZddlZddlmZ ddlmZ ddlmZ ddlm	Z	 ddlm
Z
 dd	l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ZerdndZndZdZ edd          Zedeed         f         Z ej        d          Zej        ej        k    re                    ej                   d-dZ e            Zde d<   d.d!Z!d/d#Z"eej#        d$f         Z$ G d% d          Z% G d& d$          Z&	 d0d1d*Z' G d+ d,          Z(dS )2a  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.

    )annotationsN)Any)Optional)overload)Set)Type)TypeVar)Union   )py311)py38)LiteralT   F_IT
Identified)bounddebug
sqlalchemyloggerlogging.LoggerreturnNonec                    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)r   handlers     ]/var/www/api.easyaligner.net/htdocs/venv_linux/lib/python3.11/site-packages/sqlalchemy/log.py_add_default_handlerr#   :   sW    #CJ//GJKK   g    zSet[Type[Identified]]_logged_classesclsType[Identified]strc                H    t          | dd           p| j        dz   | j        z   S )N_sqla_logger_namespace.)getattr
__module____name__)r&   s    r"   _qual_logger_name_for_clsr/   E   s-    -t44 	/>C#,.r$   	Type[_IT]c                    t          j        t          |                     fd| _        fd| _        | _        t                              |            | S )Nc                B                         t          j                  S N)isEnabledForr   DEBUGselfr   s    r"   <lambda>zclass_logger.<locals>.<lambda>N   s    )<)<* * r$   c                B                         t          j                  S r3   )r4   r   INFOr6   s    r"   r8   zclass_logger.<locals>.<lambda>Q   s    (;(;) ) r$   )r   	getLoggerr/   _should_log_debug_should_log_infor   r%   add)r&   r   s    @r"   class_loggerr?   L   sp    8==>>F   C   C CJJr$   InstanceLoggerc                  F    e Zd ZU dZdZded<   ded<   ded<   ddZddZdS )r    NzOptional[str]logging_name_IdentifiedLoggerTyper   _EchoFlagType_echor   boolc                J    | j                             t          j                  S r3   )r   r4   r   r5   r7   s    r"   r<   zIdentified._should_log_debuge   s    {''666r$   c                J    | j                             t          j                  S r3   )r   r4   r   r:   rI   s    r"   r=   zIdentified._should_log_infoh   s    {''555r$   )r   rG   )r.   r-   __qualname__	__slots__rC   __annotations__r<   r=   rB   r$   r"   r   r   \   sl         I"&L&&&&!!!!7 7 7 76 6 6 6 6 6r$   c                      e Zd ZU dZej        ej        ej        ej        dZde	d<   dZ
dd	ZddZddZddZeZddZddZddZddZd dZd!dZdS )"r@   a  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
    )NFTr   rE   rF   )echor   rO   namer(   c                    || _         t          j        |          | _        | j        |         t          j        k    r"| j        j        st          | j                   d S d S d S r3   )rO   r   r;   r   	_echo_mapr:   handlersr#   )r7   rO   rP   s      r"   __init__zInstanceLogger.__init__   s_    	'-- >$7<//8L/ ----- 0///r$   msgargsr   kwargsr   r   c                >     | j         t          j        |g|R i | dS )z/Delegate a debug call to the underlying logger.N)logr   r5   r7   rU   rV   rW   s       r"   r   zInstanceLogger.debug   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)rY   r   r:   rZ   s       r"   infozInstanceLogger.info   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)rY   r   WARNINGrZ   s       r"   warningzInstanceLogger.warning   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rY   r   ERRORrZ   s       r"   errorzInstanceLogger.error   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.r   exc_infoNra   rZ   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)rY   r   CRITICALrZ   s       r"   criticalzInstanceLogger.critical   s1     	!3888888888r$   levelintc                4   | j         j        j        |k    rdS | j        | j                 }|t
          j        k    r| j                                         }||k    r?t          r!|	                    dd          t          z   |d<    | 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
stacklevelr   )r   managerdisablerR   rO   r   NOTSETgetEffectiveLevel
STACKLEVELgetSTACKLEVEL_OFFSET_log)r7   rj   rU   rV   rW   selected_levels         r"   rY   zInstanceLogger.log   s     ;&%//F	2W^++![::<<NN"" JJ|Q//2CC |$ DKUC8888888 #"r$   rG   c                `    | j         j        j        |k    rdS ||                                 k    S )z)Is this logger enabled for level 'level'?F)r   rn   ro   rq   r7   rj   s     r"   r4   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?)rR   rO   r   rp   r   rq   rx   s     r"   rq   z InstanceLogger.getEffectiveLevel   s7     ty)GN""K1133Er$   N)rO   rE   rP   r(   )rU   r(   rV   r   rW   r   r   r   )
rj   rk   rU   r(   rV   r   rW   r   r   r   )rj   rk   r   rG   )r   rk   )r.   r-   rK   __doc__r   rp   r:   r5   rR   rM   rL   rT   r   r\   r_   warnrc   rf   ri   rY   r4   rq   rB   r$   r"   r@   r@   l   s$         ( n~l	 I "I. . . .6 6 6 6
5 5 5 5
8 8 8 8
 D6 6 6 66 6 6 69 9 9 9
9 9 9 961 1 1 1     r$   instanceechoflagrE   c                    | j         rt          | j                  d| j         }nt          | j                  }|| _        |dv rt	          j        |          }nt          ||          }|| _        dS )zEcreate a logger for an instance that implements :class:`.Identified`.r+   )FNN)rC   r/   	__class__rF   r   r;   r@   r   )r|   r}   rP   r   s       r"   instance_loggerr      s    
  =%h&89999!!

 ));<<HN =   "4((
  $//HOOOr$   c                  R    e Zd ZdZedd            Zedd
            ZddZd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``.
    r|   Literal[None]ownerr'   r   c                    d S r3   rB   r7   r|   r   s      r"   __get__zecho_property.__get__  	     r$   r   rE   c                    d S r3   rB   r   s      r"   r   zecho_property.__get__  r   r$   Optional[Identified]#Union[echo_property, _EchoFlagType]c                    || S |j         S r3   )rF   r   s      r"   r   zecho_property.__get__  s     K>!r$   valuer   c                (    t          ||           d S )N)r}   )r   )r7   r|   r   s      r"   __set__zecho_property.__set__  s    5111111r$   N)r|   r   r   r'   r   r   )r|   r   r   r'   r   rE   )r|   r   r   r'   r   r   )r|   r   r   rE   r   r   )r.   r-   rK   rz   r   r   r   rB   r$   r"   r   r     s        G    X    X" " " "2 2 2 2 2 2r$   r   )r   r   r   r   )r&   r'   r   r(   )r&   r0   r   r0   r3   )r|   r   r}   rE   r   r   ))rz   
__future__r   r   r   typingr   r   r   r   r   r	   r
   utilr   r   util.typingr   rr   rt   r   rG   rE   r;   
rootloggerrj   rp   setLevelWARNr#   setr%   rM   r/   r?   LoggerrD   r   r@   r   r   rB   r$   r"   <module>r      s  
 
 
 # " " " " "  



                                                                    J #)Jge<(((dD''"223
 W|,,
w~%%%%%    *- . . . .   
 
 
 
 gn.>>? 6 6 6 6 6 6 6 6 u u u u u u u ur 59    <2 2 2 2 2 2 2 2 2 2r$   