HEX
Server: LiteSpeed
System: Linux s1049.use1.mysecurecloudhost.com 4.18.0-477.27.2.lve.el8.x86_64 #1 SMP Wed Oct 11 12:32:56 UTC 2023 x86_64
User: xedaptot (3356)
PHP: 8.3.31
Disabled: NONE
Upload Files
File: //opt/saltstack/salt/lib/python3.10/site-packages/aiohttp/__pycache__/web_log.cpython-310.pyc
o

;j'!�@s�ddlZddlZddlZddlZddlZddlZddlmZddl	m
Z
mZmZddl
mZddlmZddlmZGdd	�d	e�ZGd
d�de�ZdS)�N)�Iterable)�Callable�ClassVar�
NamedTuple�)�AbstractAccessLogger)�BaseRequest)�StreamResponsec@s8eZdZUeeeefBed<eeee	gefed<dS)�	KeyMethod�key�methodN)
�__name__�
__module__�__qualname__�str�tuple�__annotations__rrr	�float�rr�C/opt/saltstack/salt/lib/python3.10/site-packages/aiohttp/web_log.pyr
s
r
c
s�eZdZUdZdddddddd	d
ddd
�ZdZe�d�Ze�d�Z	iZ
eee
eeeffed<dZeejdBed<dZeeed<efdejdeddf�fdd�
Zdede
eeeffdd�Zedededed edef
d!d"��Zedededed edef
d#d$��Zededed edefd%d&��Z e!dejfd'd(��Z"ededed edefd)d*��Z#ededed edefd+d,��Z$ededed edefd-d.��Z%ededed ede&fd/d0��Z'ededed ede&fd1d2��Z(ededed edefd3d4��Z)ededed edefd5d6��Z*ededed edefd7d8��Z+deded ede,e
ee
eefBeffd9d:�Z-e.de/fd;d<��Z0deded eddfd=d>�Z1�Z2S)?�AccessLoggera�Helper object to log access.

    Usage:
        log = logging.getLogger("spam")
        log_format = "%a %{User-Agent}i"
        access_logger = AccessLogger(log, log_format)
        access_logger.log(request, response, time)

    Format:
        %%  The percent sign
        %a  Remote IP-address (IP-address of proxy if using reverse proxy)
        %t  Time when the request was started to process
        %P  The process ID of the child that serviced the request
        %r  First line of request
        %s  Response status code
        %b  Size of response in bytes, including HTTP headers
        %T  Time taken to serve the request, in seconds
        %Tf Time taken to serve the request, in seconds with floating fraction
            in .06f format
        %D  Time taken to serve the request, in microseconds
        %{FOO}i  request.headers['FOO']
        %{FOO}o  response.headers['FOO']
        %{FOO}e  os.environ['FOO']

    Zremote_addressZrequest_start_timeZ
process_idZfirst_request_lineZresponse_statusZ
response_sizeZrequest_timeZrequest_time_fracZrequest_time_microZrequest_headerZresponse_header)�a�t�P�r�s�b�TZTf�D�i�oz/%a %t "%r" %s %b "%{Referer}i" "%{User-Agent}i"z.%(\{([A-Za-z0-9\-_]+)\}([ioe])|[atPrsbOD]|Tf?)z(%[^s])�
_FORMAT_CACHEN�
_cached_tzg�_cached_tz_expires�logger�
log_format�returncsDt�j||d�tj�|�}|s|�|�}|tj|<|\|_|_dS)z�Initialise the logger.

        logger is a logger object to be used for logging.
        log_format is a string with apache compatible log format description.

        )r%N)�super�__init__rr!�get�compile_format�_log_format�_methods)�selfr$r%Z_compiled_format��	__class__rrr(Es

zAccessLogger.__init__cCs�t�}|j�|�D]B}|ddkr'|j|d}ttd|d�}t||�}n|j|d|df}ttd|d�}t|t�||d��}|�	|�q	|j�
d|�}|j�
d|�}||fS)a�Translate log_format into form usable by modulo formatting

        All known atoms will be replaced with %s
        Also methods for formatting of those atoms will be added to
        _methods in appropriate order

        For example we have log_format = "%a %t"
        This format will be translated to "%s %s"
        Also contents of _methods will be
        [self._format_a, self._format_t]
        These method will be called and results will be passed
        to translated string format.

        Each _format_* method receive 'args' which is list of arguments
        given to self.log

        Exceptions are _format_e, _format_i and _format_o methods which
        also receive key name (by functools.partial)

        r�rz
_format_%s�z%sz%\1)�list�	FORMAT_RE�findall�LOG_FORMAT_MAP�getattrrr
�	functools�partial�append�sub�
CLEANUP_RE)r-r%�methodsZatomZformat_key1�mZ
key_methodZformat_key2rrrr*UszAccessLogger.compile_formatr�request�response�timecCs|durdS|j�|d�S)Nz(no headers)�-��headersr)�rr>r?r@rrr�	_format_i~szAccessLogger._format_icCs|j�|d�S�NrArBrDrrr�	_format_o�szAccessLogger._format_ocCs"|durdS|j}|dur|SdSrF)Zremote)r>r?r@�iprrr�	_format_a�szAccessLogger._format_acCs�|jdust��|jkrAt��j}t�tj|d��|_}tj�	|�}|tjdd�}|j
|jdkr4dndddd�}|��|_|Stj�	|j�S)N��seconds�)�minutesr)�minute�second�microsecond)
r"�time_modr@r#�	localtime�	tm_gmtoff�datetime�timezone�	timedelta�now�replacerN�	timestamp)�cls�gmtoff�tzrW�drrr�_get_local_time�s

zAccessLogger._get_local_timecCs"t��}|tj|d�}|�d�S)NrJz[%d/%b/%Y:%H:%M:%S %z])rr^rTrV�strftime)r>r?r@rWZ
start_timerrr�	_format_t�s
zAccessLogger._format_tcCsdt��S)Nz<%s>)�os�getpid�r>r?r@rrr�	_format_P��zAccessLogger._format_PcCs2|durdS|j�d|j�d|jj�d|jj��S)NrA� z HTTP/�.)rZpath_qs�version�major�minorrcrrr�	_format_r�s&zAccessLogger._format_rcC�|jS�N)�statusrcrrr�	_format_s��zAccessLogger._format_scCrlrm)�body_lengthrcrrr�	_format_b�rpzAccessLogger._format_bcCstt|��Srm�r�roundrcrrr�	_format_T�rezAccessLogger._format_TcCsd|S)Nz%06frrcrrr�
_format_Tf�szAccessLogger._format_TfcCstt|d��S)Ni@Brsrcrrr�	_format_D�szAccessLogger._format_Dcs���fdd�|jD�S)Ncs g|]\}}||����f�qSrr)�.0rrrcrr�
<listcomp>�s z-AccessLogger._format_line.<locals>.<listcomp>)r,)r-r>r?r@rrcr�_format_line�szAccessLogger._format_linecCs|j�tj�S)zCheck if logger is enabled.)r$�isEnabledFor�logging�INFO)r-rrr�enabled�szAccessLogger.enabledcCs�zE|�|||�}t�}t�}|D]%\}}|�|�t|t�r#|||<q|\}	}
|�|	i�}|||
<|||	<q|jj|j	t
|�|d�WdStyU|j�d�YdSw)N)�extrazError in logging)
rzr2�dictr9�
isinstancerr)r$�infor+r�	Exception�	exception)r-r>r?r@Zfmt_info�valuesrr�valueZk1Zk2�dctrrr�log�s 



 �zAccessLogger.log)3r
rr�__doc__r5Z
LOG_FORMAT�re�compiler3r;r!r�rrr2r
rr"rrTrUr#rr|�Loggerr(r*�staticmethodrr	rErGrI�classmethodr^r`rdrk�introrrrurvrwrrz�property�boolr~r��
__classcell__rrr.rrs�
�

  )�����	��������
�"r)rTr7r|rar�r@rQ�collections.abcr�typingrrr�abcrZweb_requestrZweb_responser	r
rrrrr�<module>s