HEX
Server: Apache
System: Linux server2.voipitup.com.au 4.18.0-553.104.1.lve.el8.x86_64 #1 SMP Tue Feb 10 20:07:30 UTC 2026 x86_64
User: posscale (1027)
PHP: 8.2.29
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //opt/alt/python38/lib64/python3.8/site-packages/aiohttp/__pycache__/web_log.cpython-38.opt-1.pyc
U

'�7`J�@s�ddlZddlZddlZddlZddlZddlmZddlmZm	Z	m
Z
mZmZm
Z
ddlmZddlmZddlmZedd	�ZGd
d�de�ZdS)�N)�
namedtuple)�Any�Callable�Dict�Iterable�List�Tuple�)�AbstractAccessLogger)�BaseRequest)�StreamResponse�	KeyMethodz
key methodcs�eZdZdZdddddddd	d
ddd
�ZdZe�d�Ze�d�Z	iZ
efeje
dd��fdd�
Ze
ee
eefd�dd�Zee
eeee
d�dd��Zee
eeee
d�dd��Zeeeee
d�dd��Zeeeee
d�d d!��Zeeeee
d�d"d#��Zeeeee
d�d$d%��Zeeeeed�d&d'��Zeeeeed�d(d)��Zeeeee
d�d*d+��Z eeeee
d�d,d-��Z!eeeee
d�d.d/��Z"eeee#ee
e$eeege
ffd�d0d1�Z%eeedd�d2d3�Z&�Z'S)4�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])N)�logger�
log_format�returncsDt�j||d�tj�|�}|s4|�|�}|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.

        )rN)�super�__init__r�
_FORMAT_CACHE�get�compile_format�_log_format�_methods)�selfrrZ_compiled_format��	__class__��B/opt/alt/python38/lib64/python3.8/site-packages/aiohttp/web_log.pyr>s

zAccessLogger.__init__)rrcCs�t�}|j�|�D]�}|ddkrN|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_key2r&r&r'r NszAccessLogger.compile_format)�key�request�response�timercCs|dkrdS|j�|d�S)Nz(no headers)�-�Zheadersr�r6r7r8r9r&r&r'�	_format_iwszAccessLogger._format_icCs|j�|d�S�Nr:r;r<r&r&r'�	_format_o�szAccessLogger._format_o)r7r8r9rcCs"|dkrdS|j}|dk	r|SdSr>)Zremote)r7r8r9Zipr&r&r'�	_format_a�szAccessLogger._format_acCs$tj��}|tj|d�}|�d�S)N)Zsecondsz[%d/%b/%Y:%H:%M:%S +0000])�datetimeZutcnowZ	timedelta�strftime)r7r8r9ZnowZ
start_timer&r&r'�	_format_t�s
zAccessLogger._format_tcCsdt��S)Nz<%s>)�os�getpid�r7r8r9r&r&r'�	_format_P�szAccessLogger._format_PcCs(|dkrdSd�|j|j|jj|jj�S)Nr:z{} {} HTTP/{}.{})�format�methodZpath_qs�version�major�minorrFr&r&r'�	_format_r�s�zAccessLogger._format_rcCs|jS�N)�statusrFr&r&r'�	_format_s�szAccessLogger._format_scCs|jSrN)Zbody_lengthrFr&r&r'�	_format_b�szAccessLogger._format_bcCstt|��SrN��str�roundrFr&r&r'�	_format_T�szAccessLogger._format_TcCsd|S)Nz%06fr&rFr&r&r'�
_format_Tf�szAccessLogger._format_TfcCstt|d��S)Ni@BrRrFr&r&r'�	_format_D�szAccessLogger._format_Dcs���fdd�|jD�S)Ncs g|]\}}||����f�qSr&r&)�.0r6rIrFr&r'�
<listcomp>�sz-AccessLogger._format_line.<locals>.<listcomp>)r")r#r7r8r9r&rFr'�_format_line�szAccessLogger._format_linecCs�z�|�|||�}t�}t�}|D]J\}}|�|�|jtkrF|||<q |\}	}
|�|	i�}|||
<|||	<q |jj|j	t
|�|d�Wn tk
r�|j�d�YnXdS)N)�extrazError in logging)
rZr*�dictr1r%rSrr�infor!�tuple�	ExceptionZ	exception)r#r7r8r9Zfmt_info�valuesr[r6�valueZk1Zk2�dctr&r&r'�log�s



zAccessLogger.log)(�__name__�
__module__�__qualname__�__doc__r-Z
LOG_FORMAT�re�compiler+r3r�loggingZLoggerrSrrrr
r �staticmethodrr�floatr=r?r@rCrGrM�intrPrQrUrVrWrrrZrc�
__classcell__r&r&r$r'rsr�

)�	�
�r)rAr/rjrDrh�collectionsr�typingrrrrrr�abcr
Zweb_requestrZweb_responserr
rr&r&r&r'�<module>s