Your IP : 13.58.110.182


Current Path : /opt/cloudlinux/venv/lib64/python3.11/site-packages/aiohttp/__pycache__/
Upload File :
Current File : //opt/cloudlinux/venv/lib64/python3.11/site-packages/aiohttp/__pycache__/web_log.cpython-311.pyc

�

��bgy���ddlZddlZddlZddlZddlZddlZddlmZddl	m
Z
mZmZm
Z
mZmZddlmZddlmZddlmZedd	��ZGd
�de��ZdS)�N)�
namedtuple)�Any�Callable�Dict�Iterable�List�Tuple�)�AbstractAccessLogger)�BaseRequest)�StreamResponse�	KeyMethodz
key methodc�(��eZdZUdZdddddddd	d
ddd
�ZdZejd��Zejd��Z	iZ
eee
eeeffed<efdejdeddf�fd�
Zdede
eeeffd�Zedededededef
d���Zedededededef
d���Zededededefd���Zededededefd���Zededededefd ���Zededededefd!���Zededededefd"���Z ededededefd#���Z!ededededefd$���Z"ededededefd%���Z#ededededefd&���Z$dededede%e
ee&eeegefffd'�Z'dedededdfd(�Z(�xZ)S))�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']

    �remote_address�request_start_time�
process_id�first_request_line�response_status�
response_size�request_time�request_time_frac�request_time_micro�request_header�response_header)�a�t�P�r�s�b�T�Tf�D�i�oz/%a %t "%r" %s %b "%{Referer}i" "%{User-Agent}i"z.%(\{([A-Za-z0-9\-_]+)\}([ioe])|[atPrsbOD]|Tf?)z(%[^s])�
_FORMAT_CACHE�logger�
log_format�returnNc���t���||���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)�_compiled_format�	__class__s    ��F/opt/cloudlinux/venv/lib64/python3.11/site-packages/aiohttp/web_log.pyr-zAccessLogger.__init__?sv���	������J��7�7�7�'�5�9�9�*�E�E���	F�#�2�2�:�>�>��5E�L�&�z�2�*:�'���$�-�-�-�c	�V�t��}|j�|��D]�}|ddkrB|j|d}t	t
d|dz��}t
||��}nb|j|d|df}t	t
d|dz��}t
|tj||d����}|�	|����|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)r2r)�methods�atom�format_key1�m�
key_method�format_key2s        r5r/zAccessLogger.compile_formatOs��.�&�&���N�*�*�:�6�6�
	'�
	'�D��A�w�"�}�}�"�1�$�q�'�:���L�,��a��*@�A�A��&�{�A�6�6�
�
�#�2�4��7�;�T�!�W�E���L�,��a��*@�A�A��&�{�I�4E�a��a��4Q�4Q�R�R�
��N�N�:�&�&�&�&��^�'�'��z�:�:�
��_�(�(���<�<�
��7�"�"r6�key�request�response�timec�@�|�dS|j�|d��S)Nz(no headers)�-��headersr.�rJrKrLrMs    r5�	_format_izAccessLogger._format_ixs(���?�!�>���"�"�3��,�,�,r6c�8�|j�|d��S�NrOrPrRs    r5�	_format_ozAccessLogger._format_o�s��
��#�#�C��-�-�-r6c�$�|�dS|j}|�|ndSrU)�remote)rKrLrM�ips    r5�	_format_azAccessLogger._format_a�s!���?��3�
�^���^�r�r��,r6c��tjtjtj�����}tj�|��}|tj|���z
}|�d��S)N)�secondsz[%d/%b/%Y:%H:%M:%S %z])�datetime�timezone�	timedelta�time_mod�now�strftime)rKrLrM�tzra�
start_times      r5�	_format_tzAccessLogger._format_t�si��
�
�x�1�8�;L�:L�M�M�M�
N�
N����#�#�B�'�'���8�-�d�;�;�;�;�
��"�"�#;�<�<�<r6c�.�dtj��zS)Nz<%s>)�os�getpid�rKrLrMs   r5�	_format_PzAccessLogger._format_P�s����	���#�#r6c�v�|�dSd�|j|j|jj|jj��S)NrOz{} {} HTTP/{}.{})�format�method�path_qs�version�major�minorris   r5�	_format_rzAccessLogger._format_r�s>���?��3�!�(�(��N��O��O�!��O�!�	
�
�	
r6c��|jS�N)�statusris   r5�	_format_szAccessLogger._format_s�s
����r6c��|jSrt)�body_lengthris   r5�	_format_bzAccessLogger._format_b�s���#�#r6c�:�tt|����Srt��str�roundris   r5�	_format_TzAccessLogger._format_T�s���5��;�;���r6c��d|zS)Nz%06f�ris   r5�
_format_TfzAccessLogger._format_Tf�s����}�r6c�@�tt|dz����S)Ni@Br{ris   r5�	_format_DzAccessLogger._format_D�s���5����(�(�)�)�)r6c�2�������fd�|jD��S)Nc�4��g|]\}}||�����f��Sr�r�)�.0rJrmrKrLrMs   ���r5�
<listcomp>z-AccessLogger._format_line.<locals>.<listcomp>�s0���X�X�X�;�3���f�f�W�h��5�5�6�X�X�Xr6)r1)r2rKrLrMs ```r5�_format_linezAccessLogger._format_line�s*�����Y�X�X�X�X�X�$�-�X�X�X�Xr6c��|j�tj��sdS	|�|||��}t��}t
��}|D]S\}}|�|��|jtur|||<�.|\}	}
|�
|	i��}|||
<|||	<�T|j�|jt|��z|���dS#t$r|j�d��YdSwxYw)N)�extrazError in logging)r(�isEnabledFor�logging�INFOr�r:�dictrAr4r|r.�infor0�tuple�	Exception�	exception)r2rKrLrM�fmt_info�valuesr�rJ�value�k1�k2�dcts            r5�logzAccessLogger.log�s&���{�'�'���5�5�	��F�	6��(�(��(�D�A�A�H��V�V�F��F�F�E�&�	
$�	
$�
��U��
�
�e�$�$�$��=�C�'�'�!&�E�#�J�J� �F�B���)�)�B��+�+�C�#�C��G� #�E�"�I�I��K���T�-��f�
�
�=�U��K�K�K�K�K���	6�	6�	6��K�!�!�"4�5�5�5�5�5�5�	6���s�B:C$�$$D�D)*�__name__�
__module__�__qualname__�__doc__r=�
LOG_FORMAT�re�compiler;rCr'rr|r	rr�__annotations__r��Loggerr-r/�staticmethodrr
�floatrSrVrZrerjrr�intrvryr~r�r�rrr�r��
__classcell__)r4s@r5rrs^����������6�
!�
�
!�
�
�
�!�
!�
�
���N�C�J���
�L�M�M�I����J�'�'�J�<>�M�4��U�3��Y��#7�8�8�9�>�>�>�AK�;�;�w�~�;�3�;�PT�;�;�;�;�;�;� '#��'#��s�D��O�7K�1L�'#�'#�'#�'#�R�-�
�-�&�-�2@�-�HM�-�	�-�-�-��\�-��.�
�.�&�.�2@�.�HM�.�	�.�.�.��\�.��-�;�-�.�-��-�RU�-�-�-��\�-��=�;�=�.�=��=�RU�=�=�=��\�=��$�;�$�.�$��$�RU�$�$�$��\�$��
�;�
�.�
��
�RU�
�
�
��\�
���;��.����RU�����\���$�;�$�.�$��$�RU�$�$�$��\�$�� �;� �.� �� �RU� � � ��\� ���K��>����SV�����\���*�;�*�.�*��*�RU�*�*�*��\�*�Y�"�Y�.<�Y�DI�Y�	�%��X�{�N�E�&J�C�&O�P�P�Q�	R�Y�Y�Y�Y�
6�;�6�.�6��6�RV�6�6�6�6�6�6�6�6r6r)r]r?r�rgr�rMr`�collectionsr�typingrrrrrr	�abcr�web_requestr�web_responser
rrr�r6r5�<module>r�s	��������������	�	�	�	�	�	�	�	�����"�"�"�"�"�"�=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�=�%�%�%�%�%�%�$�$�$�$�$�$�(�(�(�(�(�(��J�{�L�1�1�	�D6�D6�D6�D6�D6�'�D6�D6�D6�D6�D6r6

?>