HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //usr/local/lib/python3.10/dist-packages/sqlalchemy/__pycache__/log.cpython-310.pyc
o

���g�!�@snUdZddlmZddlZddlZddlmZddlmZddlmZddlm	Z	ddlm
Z
dd	lmZdd
lmZddl
mZdd
l
mZddlmZerXdZerUdndZndZdZeddd�ZedeedfZe�d�Zejejkr|e�ej�d1dd�Ze�Zde d<d2d"d#�Z!d3d%d&�Z"eej#d'fZ$Gd(d�d�Z%Gd)d'�d'�Z&	d4d5d-d.�Z'Gd/d0�d0�Z(dS)6a�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�NonecCs*t�tj�}|�t�d��|�|�dS)Nz.%(asctime)s %(levelname)s %(name)s %(message)s)�logging�
StreamHandler�sys�stdout�setFormatter�	Formatter�
addHandler)r�handler�r �9/usr/local/lib/python3.10/dist-packages/sqlalchemy/log.py�_add_default_handler:s
�r"zSet[Type[Identified]]�_logged_classes�cls�Type[Identified]�strcCst|dd�p
|jd|jS)N�_sqla_logger_namespace�.)�getattr�
__module__�__name__�r$r r r!�_qual_logger_name_for_clsEs�r-�	Type[_IT]cs>t�t|����fdd�|_�fdd�|_�|_t�|�|S)Nc���tj�S�N)�isEnabledForr�DEBUG��self�rr r!�<lambda>N��zclass_logger.<locals>.<lambda>cr/r0)r1r�INFOr3r5r r!r6Qr7)r�	getLoggerr-�_should_log_debug�_should_log_inforr#�addr,r r5r!�class_loggerLs
r=�InstanceLoggerc@sBeZdZUdZdZded<ded<ded<ddd�Zdd
d�ZdS)rr Nz
Optional[str]�logging_name�_IdentifiedLoggerTyper�
_EchoFlagType�_echor�boolcC�|j�tj�Sr0)rr1rr2r3r r r!r:e�zIdentified._should_log_debugcCrDr0)rr1rr8r3r r r!r;hrEzIdentified._should_log_info)rrC)r+r*�__qualname__�	__slots__r?�__annotations__r:r;r r r r!r\s

c@s�eZdZUdZejejejejd�Zde	d<dZ
d'd	d
�Zd(dd�Zd(dd�Z
d(dd�ZeZd(dd�Zd(dd�Zd(dd�Zd)dd �Zd*d"d#�Zd+d$d%�Zd&S),r>aA 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
    )NFTrrArB)�echorrI�namer&cCs@||_t�|�|_|j|tjkr|jjst|j�dSdSdSr0)rIrr9r�	_echo_mapr8�handlersr")r4rIrJr r r!�__init__�s
�zInstanceLogger.__init__�msg�argsr�kwargsrrcO� |jtj|g|�Ri|��dS)z/Delegate a debug call to the underlying logger.N)�logrr2�r4rNrOrPr r r!r�� zInstanceLogger.debugcOrQ)z/Delegate an info call to the underlying logger.N)rRrr8rSr r r!�info�rTzInstanceLogger.infocOrQ)z1Delegate a warning call to the underlying logger.N)rRr�WARNINGrSr r r!�warning�rTzInstanceLogger.warningcOrQ)zB
        Delegate an error call to the underlying logger.
        N�rRr�ERRORrSr r r!�error�s zInstanceLogger.errorcOs(d|d<|jtj|g|�Ri|��dS)z4Delegate an exception call to the underlying logger.r
�exc_infoNrXrSr r r!�	exception�s zInstanceLogger.exceptioncOrQ)z2Delegate a critical call to the underlying logger.N)rRr�CRITICALrSr r r!�critical�rTzInstanceLogger.critical�level�intcOsr|jjj|kr	dS|j|j}|tjkr|j��}||kr7tr)|�	dd�t
|d<|jj|||fi|��dSdS)z�Delegate 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�disablerKrIr�NOTSET�getEffectiveLevel�
STACKLEVEL�get�STACKLEVEL_OFFSET�_log)r4r_rNrOrP�selected_levelr r r!rR�s

��zInstanceLogger.logrCcCs|jjj|kr	dS||��kS)z)Is this logger enabled for level 'level'?F)rrbrcre�r4r_r r r!r1�szInstanceLogger.isEnabledForcCs$|j|j}|tjkr|j��}|S)z+What's the effective level for this logger?)rKrIrrdrrerkr r r!re�s

z InstanceLogger.getEffectiveLevelN)rIrArJr&)rNr&rOrrPrrr)
r_r`rNr&rOrrPrrr)r_r`rrC)rr`)r+r*rF�__doc__rrdr8r2rKrHrGrMrrUrW�warnrZr\r^rRr1rer r r r!r>ls(
�








�instance�echoflagrAcCsT|jrdt|j�|jf}nt|j�}||_|dvr t�|�}nt||�}||_dS)zEcreate a logger for an instance that implements :class:`.Identified`.z%s.%s)FNN)r?r-�	__class__rBrr9r>r)rnrorJrr r r!�instance_logger�s�


rqc@s@eZdZdZeddd��Zeddd��Zddd�Zddd�ZdS)�
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``.
    rn�
Literal[None]�ownerr%rcC�dSr0r �r4rnrtr r r!�__get__
�zecho_property.__get__rrAcCrur0r rvr r r!rwrx�Optional[Identified]�#Union[echo_property, _EchoFlagType]cCs|dur|S|jSr0)rBrvr r r!rws�valuercCst||d�dS)N)ro)rq)r4rnr{r r r!�__set__szecho_property.__set__N)rnrsrtr%rrr)rnrrtr%rrA)rnryrtr%rrz)rnrr{rArr)r+r*rFrlrrwr|r r r r!rrs

rr)rrrr)r$r%rr&)r$r.rr.r0)rnrrorArr))rl�
__future__rrr�typingrrrrrrr	�utilrr�util.typingr
rfrhrrCrAr9�
rootloggerr_rd�setLevel�WARNr"�setr#rHr-r=�Loggerr@rr>rqrrr r r r!�<module>sD




y�