Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
web_log.cpython-313.pyc99 linesDownload Raw Back to __pycache__
1�

2��j�"���SSKrSSKrSSKrSSKrSSKrSSKrSSKJr SSK	J3r4 SSKJrJ
r
JrJrJrJr SSKJr SSKJr SSKJr \"S	S55r"SS\5rg)
�N)�6namedtuple)�Iterable)�Callable�ClassVar�Dict�List�Optional�Tuple�)�AbstractAccessLogger)�BaseRequest)�StreamResponse�	KeyMethodz7key methodc�x^�\rSrSr%SrSSSSSSS	S8SSS
S.rSr\R"S5r	\R"S5r90r\\
\\
\\44\S'Sr\\\R,\S'Sr\\\S'\4S\R4S\
SS4U4SjjjrS\
S\\
\\44Sjr\S\
S\S\S\S\
410S j5r \S\
S\S\S\S\
411S!j5r!\S\S\S\S\
4S"j5r"\#S\R*4S#j5r$\S\S\S\S\
4S$j5r%\S\S\S\S\
4S%j5r&\S\S\S\S\
4S&j5r'\S\S\S\S\(4S'j5r)\S\S\S\S\(4S(j5r*\S\S\S\S\
4S)j5r+\S\S\S\S\
4S*j5r,\S\S\S\S\
4S+j5r-S\S\S\S\.\\
\/\\\/\
444S,jr0\1S\24S-j5r3S\S\S\SS4S.jr4S/r5U=r6$)0�AccessLogger�aXHelper object to log access.12 13Usage:14    log = logging.getLogger("spam")15    log_format = "%a %{User-Agent}i"16    access_logger = AccessLogger(log, log_format)17    access_logger.log(request, response, time)18 19Format:20    %%  The percent sign21    %a  Remote IP-address (IP-address of proxy if using reverse proxy)22    %t  Time when the request was started to process23    %P  The process ID of the child that serviced the request24    %r  First line of request25    %s  Response status code26    %b  Size of response in bytes, including HTTP headers27    %T  Time taken to serve the request, in seconds28    %Tf Time taken to serve the request, in seconds with floating fraction29        in .06f format30    %D  Time taken to serve the request, in microseconds31    %{FOO}i  request.headers['FOO']32    %{FOO}o  response.headers['FOO']33    %{FOO}e  os.environ['FOO']34 35�remote_address�request_start_time�36process_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_CACHEN�37_cached_tzg�_cached_tz_expires�logger�38log_format�returnc��>�[TU]XS9 [RR	U5nU(d$URU5nU[RU'UuUlUlg)z�Initialise the logger.39 40logger is a logger object to be used for logging.41log_format is a string with apache compatible log format description.42 43)r-N)�super�__init__rr)�get�compile_format�_log_format�_methods)�selfr,r-�_compiled_format�	__class__s    ��UD:\code\apps\devtools\python\user_packages\Python313\site-packages\aiohttp/web_log.pyr1�AccessLogger.__init__Cs_���	�����7�'�5�5�9�9�*�E���#�2�2�:�>��5E�L�&�&�z�2�*:�'���$�-�c	��[5nURRU5H�nUSS:Xa4URUSn[	[44SUS-5n[
XE5nOPURUSUS4n[	[45SUS-5n[
U[R"XSS55nURU5 M� URRSU5nURRSU5nX4$)alTranslate log_format into form usable by modulo formatting46 47All known atoms will be replaced with %s48Also methods for formatting of those atoms will be added to49_methods in appropriate order50 51For example we have log_format = "%a %t"52This format will be translated to "%s %s"53Also contents of _methods will be54[self._format_a, self._format_t]55These method will be called and results will be passed56to translated string format.57 58Each _format_* method receive 'args' which is list of arguments59given to self.log60 61Exceptions are _format_e, _format_i and _format_o methods which62also receive key name (by functools.partial)63 64r�rz65_format_%s�z%sz%\1)�list�	FORMAT_RE�findall�LOG_FORMAT_MAP�getattrrr�	functools�partial�append�sub�66CLEANUP_RE)r6r-�methods�atom�format_key1�m�67key_method�format_key2s        r9r3�AccessLogger.compile_formatSs���.�&���N�N�*�*�:�6�D��A�w�"�}�"�1�1�$�q�'�:���L�,��a��*@�A��&�{�6�68�#�2�2�4��7�;�T�!�W�E���L�,��a��*@�A��&�{�I�4E�4E�a�a��4Q�R�69��N�N�:�&�7��^�^�'�'��z�:�70��_�_�(�(���<�71��"�"r;�key�request�response�timec�B�UcgURRUS5$)Nz(no headers)�-��headersr2�rPrQrRrSs    r9�	_format_i�AccessLogger._format_i|s%���?�!����"�"�3��,�,r;c�:�URRUS5$�NrUrVrXs    r9�	_format_o�AccessLogger._format_o�s��72���#�#�C��-�-r;c�0�UcgURnUbU$S$r\)�remote)rQrRrS�ips    r9�	_format_a�AccessLogger._format_a�s"���?��
�^�^���^�r�,��,r;c�0�URb#[R"5UR:�a�[R"5R73n[R"[R"US95=Uln[RRU5nU[R"SS9-nURURS:�aSOSSSS9nUR5UlU$[RRUR5$)N��seconds�)�minutesr)�minute�second�microsecond)
r*�time_modrSr+�	localtime�	tm_gmtoff�datetime�timezone�	timedelta�now�replaceri�	timestamp)�cls�gmtoff�tzrr�ds     r9�_get_local_time�AccessLogger._get_local_time�s����>�>�!�X�]�]�_��8N�8N�%N��'�'�)�3�3�F�"*�"3�"3�H�4F�4F�v�4V�"W�W�C�N�R��#�#�'�'��+�C��h�(�(��4�4�A��	�	�q�x�x�2�~��1�Q�TU�	�V�A�%&�[�[�]�C�"��J�� � �$�$�S�^�^�4�4r;c�z�[R5nU[R"US9-74nUR	S5$)Nrez[%d/%b/%Y:%H:%M:%S %z])rryrorq�strftime)rQrRrSrr�75start_times     r9�	_format_t�AccessLogger._format_t�s7���*�*�,���8�-�-�d�;�;�76��"�"�#;�<�<r;c�2�S[R"5-$)Nz<%s>)�os�getpid�rQrRrSs   r9�	_format_P�AccessLogger._format_P�s����	�	��#�#r;c��UcgSRURURURRURR775$)NrUz{} {} HTTP/{}.{})�format�method�path_qs�version�major�minorr�s   r9�	_format_r�AccessLogger._format_r�sE���?��!�(�(��N�N��O�O��O�O�!�!��O�O�!�!�	78�	79r;c��UR$�N)�statusr�s   r9�	_format_s�AccessLogger._format_s�s�����r;c��UR$r�)�body_lengthr�s   r9�	_format_b�AccessLogger._format_b�s���#�#�#r;c�*�[[U55$r���str�roundr�s   r9�	_format_T�AccessLogger._format_T�s���5��;��r;c��SU-$)Nz%06f�r�s   r9�80_format_Tf�AccessLogger._format_Tf�s����}�r;c�0�[[US-55$)Ni@Br�r�s   r9�	_format_D�AccessLogger._format_D�s���5����(�)�)r;c81�`�URVVs/sHupEXE"XU54PM snn$s snnfr�)r5)r6rQrRrSrPr�s      r9�_format_line�AccessLogger._format_line�s0��KO�-�-�X�-�;�3��f�W��5�6�-�X�X��Xs�*c�T�URR[R5$)zCheck if logger is enabled.)r,�isEnabledFor�logging�INFO)r6s r9�enabled�AccessLogger.enabled�s���{�{�'�'����5�5r;c��URXU5n[5n[5nUHMupxURU5 UR[82LaX�U'M/Uup�UR
U	05nX�U83'X�U	'MO URRUR[U5-US9 g![a URRS5 gf=f)N)�extrazError in logging)
r�r?�dictrFr8r�r2r,�infor4�tuple�	Exception�	exception)r6rQrRrS�fmt_info�valuesr�rP�value�k1�k2�dcts            r9�log�AccessLogger.log�s���	6��(�(��D�A�H��V�F��F�E�&�84���
�
�e�$��=�=�C�'�!&�#�J� �F�B��)�)�B��+�C�#��G� #�"�I�'�
�K�K���T�-�-��f�
�=�U��K���	6��K�K�!�!�"4�5�	6�s�B)B,�,%C�C)r4r5)7�__name__�85__module__�__qualname__�__firstlineno__�__doc__rB�86LOG_FORMAT�re�compiler@rHr)rr�r87rr�__annotations__r*rr	rorpr+�floatr��Loggerr1r3�staticmethodr
rrYr]rb�classmethodryr~r�r��intr�r�r�r�r�rrr��property�boolr�r��__static_attributes__�
__classcell__)r8s@r9rrs�����6�
!�
�
!�
�
�
�!�
!�
�
��N�C�J��88�89�L�M�I����J�'�J�<>�M�4��U�3��Y��#7�8�8�9�>�8<�J���(�"3�"3�4�5�<�*-�����-�AK�;�w�~�~�;�3�;�PT�;�;� '#��'#��s�D��O�7K�1L�'#�R�-�
�-�&�-�2@�-�HM�-�	�-��-��.�
�.�&�.�2@�.�HM�.�	�.��.��-�;�-�.�-��-�RU�-��-��5�� 1� 1�5��5��=�;�=�.�=��=�RU�=��=�90�$�;�$�.�$��$�RU�$��$��91�;�92�.�93��94�RU�95��96���;��.����RU�����$�;�$�.�$��$�RU�$��$�� �;� �.� �� �RU� �� ���K��>����SV�����*�;�*�.�*��*�RU�*��*�Y�"�Y�.<�Y�DI�Y�	�%��X�{�N�E�&J�C�&O�P�P�Q�	R�Y�97�6��6��6�986�;�6�.�6��6�RV�6�6r;r)rorDr�r�r�rSrl�collectionsr�collections.abcr�typingrrrrr	r99�abcr�web_requestr
�web_responserrrr�r;r9�<module>r�sG�����	�	��"�$�B�B�%�$�(��{�L�1�	�X6�'�X6r;
codekingpro/portable-devtools · Team Ai