관리-도구
편집 파일: log.cpython-37.pyc
B ��4]% � @ s� d Z ddlZddlZe�d�Zejejkr6e�ej� dd� Z e � Zdd� ZG dd � d e �ZG d d� de �Zddd �ZG dd� de �ZdS )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` and :class:`.Pool` objects, corresponds to a logger specific to that instance only. � N� sqlalchemyc C s* t �tj�}|�t �d�� | �|� d S )Nz.%(asctime)s %(levelname)s %(name)s %(message)s)�logging� StreamHandler�sys�stdout�setFormatter� Formatter� addHandler)�logger�handler� r �A/opt/alt/python37/lib64/python3.7/site-packages/sqlalchemy/log.py�_add_default_handler! s r c sF t �| jd | j �� � fdd�| _� fdd�| _� | _t�| � | S )N�.c s � � tj�S )N)�isEnabledForr �DEBUG)�self)r r r �<lambda>. � zclass_logger.<locals>.<lambda>c s � � tj�S )N)r r �INFO)r )r r r r / r ) r � getLogger� __module__�__name__�_should_log_debug�_should_log_infor �_logged_classes�add)�clsr )r r �class_logger, s r c @ s e Zd ZdZdd� Zdd� ZdS )� IdentifiedNc C s | j �tj�S )N)r r r r )r r r r r 8 s zIdentified._should_log_debugc C s | j �tj�S )N)r r r r )r r r r r ; s zIdentified._should_log_info)r r �__qualname__�logging_namer r r r r r r 5 s r c @ sz e Zd ZdZejejejejd�Zdd� Z dd� Z dd� Zd d � ZeZ dd� Zd d� Zdd� Zdd� Zdd� Zdd� ZdS )�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 C s8 || _ t�|�| _| j| tjkr4| jjs4t| j� d S )N)�echor r r � _echo_mapr �handlersr )r r$ �namer r r �__init__Z s zInstanceLogger.__init__c O s | j tj|f|�|� dS )z/Delegate a debug call to the underlying logger.N)�logr r )r �msg�args�kwargsr r r r# f s zInstanceLogger.debugc O s | j tj|f|�|� dS )z/Delegate an info call to the underlying logger.N)r) r r )r r* r+ r, r r r �infok s zInstanceLogger.infoc O s | j tj|f|�|� dS )z1Delegate a warning call to the underlying logger.N)r) r �WARNING)r r* r+ r, r r r �warningp s zInstanceLogger.warningc O s | j tj|f|�|� dS )zB Delegate an error call to the underlying logger. N)r) r �ERROR)r r* r+ r, r r r �errorw s zInstanceLogger.errorc O s"