HEX
Server: LiteSpeed
System: Linux us-phx-web1284.main-hosting.eu 4.18.0-553.109.1.lve.el8.x86_64 #1 SMP Thu Mar 5 20:23:46 UTC 2026 x86_64
User: u300739242 (300739242)
PHP: 8.2.30
Disabled: system, shell_exec, passthru, mysql_list_dbs, ini_alter, dl, symlink, link, chgrp, leak, popen, apache_child_terminate, virtual, mb_send_mail
Upload Files
File: //opt/alt/python311/lib/python3.11/site-packages/fluent/__pycache__/handler.cpython-311.pyc
�

��;f�!��v�ddlZddlZddlZddlmZGd�dej��ZGd�dej��ZdS)�N)�senderc�~��eZdZdZ						d�fd�	Z�fd�Zd�Zd	�Zd
�Z�fd�Z	d�Z
d
�Zd�Ze
d���Z�xZS)�FluentRecordFormattera6A structured formatter for Fluent.

    Best used with server storing data in an ElasticSearch cluster for example.

    :param fmt: a dict or a callable with format string as values to map to provided keys.
        If callable, should accept a single argument `LogRecord` and return a dict,
        and have a field `usesTime` that is callable and return a bool as would
        `FluentRecordFormatter.usesTime`
    :param datefmt: strftime()-compatible date/time format string.
    :param style: '%', '{' or '$' (used only with Python 3.2 or above)
    :param fill_missing_fmt_key: if True, do not raise a KeyError if the format
        key is not found. Put None if not found.
    :param format_json: if True, will attempt to parse message as json. If not,
        will use message as-is. Defaults to True
    :param exclude_attrs: switches this formatter into a mode where all attributes
        except the ones specified by `exclude_attrs` are logged with the record as is.
        If `None`, operates as before, otherwise `fmt` is ignored.
        Can be an iterable.
    N�%FTc���t���d|��|dkr4tjdddd�ftjdddd�fd	�|\|_}n
d|_d
ddd�}|�@t
|��|_d|_|j	|_
t��j|_nkd|_|s ||_|j|_
|j
|_nBt|��r||_
|j|_n||_|j|_
|j
|_|r
|j|_n|j|_t%j��|_||_dS)
Nrz
{hostname}z{name}z{module})�sys_host�sys_name�
sys_modulez${hostname}z${name}z	${module})�{�$z%(hostname)sz%(name)sz
%(module)s)�super�__init__�logging�StrFormatStyle�StringTemplateStyle�_FluentRecordFormatter__style�set�
_exc_attrs�	_fmt_dict�_format_by_exclusion�
_formatter�usesTime�_format_by_dict�_format_by_dict_uses_time�callable�_format_msg_json�_format_msg�_format_msg_default�socket�gethostname�hostname�fill_missing_fmt_key)	�self�fmt�datefmt�styler"�format_json�
exclude_attrs�basic_fmt_dict�	__class__s	        ��A/opt/alt/python311/lib/python3.11/site-packages/fluent/handler.pyrzFluentRecordFormatter.__init__s����	������w�'�'�'��C�<�<��*�$0�$,�&0�����/�$1�$-�&1����,�,�"�#,�(�D�L�.�.�& �D�L�*�&�*���N��$�!�-�0�0�D�O�!�D�N�"�7�D�O�!�G�G�,�D�M�M�"�D�O��
C�!/���"&�"6��� $� >��
�
��C�=�=�C�&)�D�O�$'�L�D�M�M�%(�D�N�&*�&:�D�O�$(�$B�D�M��	8�#�4�D���#�7�D���*�,�,��
�$8��!�!�!�c���t���|��|j|_|�|��}|�||��|S�N)r
�formatr!r�_structuring)r#�record�datar*s   �r+r/zFluentRecordFormatter.format`sP���
�����v�����-������v�&�&�����$��'�'�'��r,c��dS)zTThis method is substituted on construction based on settings for performance reasonsN��r#s r+rzFluentRecordFormatter.usesTimels���r,c� �|j}t|t��r|�||��dSt|t��r,|�||�||����dS|�|d|i��dS)a|Melds `msg` into `data`.

        :param data: dictionary to be sent to fluent server
        :param msg: :class:`LogRecord`'s message to add to `data`.
          `msg` can be a simple string for backward compatibility with
          :mod:`logging` framework, a JSON encoded string or a dictionary
          that will be merged into dictionary generated in :meth:`format.
        �messageN)�msg�
isinstance�dict�_add_dic�strr)r#r2r1r8s    r+r0z"FluentRecordFormatter._structuringos����j���c�4� � �	2��M�M�$��$�$�$�$�$�
��S�
!�
!�	2��M�M�$�� 0� 0��� =� =�>�>�>�>�>��M�M�$��C� 0�1�1�1�1�1r,c���	tjt|����}t|t��r|S|�||��S#t$r|�||��cYSwxYwr.)�json�loadsr<r9r:r�
ValueError)r#r1r8�json_msgs    r+rz&FluentRecordFormatter._format_msg_json�s���	9��z�#�c�(�(�+�+�H��(�D�)�)�
=����/�/���<�<�<���	9�	9�	9��+�+�F�C�8�8�8�8�8�	9���s�7A�A� A3�2A3c�J��dt���|��iS)Nr7)r
r/)r#r1r8r*s   �r+rz)FluentRecordFormatter._format_msg_default�s����5�7�7�>�>�&�1�1�2�2r,c�d�i}|j���D]\}}||jvr|||<�|Sr.)�__dict__�itemsr)r#r1r2�key�values     r+rz*FluentRecordFormatter._format_by_exclusion�sD���� �/�/�/�1�1�	"�	"�J�C���$�/�)�)�!��S�	���r,c��i}|j���D]h\}}	|jr)|�|���|��}n
||jz}n"#t
$r}d}|js|�Yd}~nd}~wwxYw|||<�i|Sr.)rrErr/rD�KeyErrorr")r#r1r2rFrG�excs      r+rz%FluentRecordFormatter._format_by_dict�s������.�.�.�0�0�	�	�J�C��
��<�4� �L�L��/�/�6�6�v�>�>�E�E�!�F�O�3�E����
�
�
����0���I����������
����
�D��I�I��s�:A�
A<�'A7�7A<c���|jr
|jj�nd�t�fd�|j���D����S)Nz
%(asctime)c�B��g|]}|����dk��S)r)�find)�.0rG�searchs  �r+�
<listcomp>zCFluentRecordFormatter._format_by_dict_uses_time.<locals>.<listcomp>�s*���Q�Q�Q��E�J�J�v�&�&�!�+�Q�Q�Qr,)r�asctime_search�anyr�values)r#rOs @r+rz/FluentRecordFormatter._format_by_dict_uses_time�sO����<�	"��\�0�F�F�!�F��Q�Q�Q�Q���9N�9N�9P�9P�Q�Q�Q�R�R�Rr,c�n�|���D]\}}t|t��r|||<� dSr.)rEr9r<)r2�dicrFrGs    r+r;zFluentRecordFormatter._add_dic�sC���)�)�+�+�	"�	"�J�C���#�s�#�#�
"�!��S�	��	"�	"r,)NNrFTN)�__name__�
__module__�__qualname__�__doc__rr/rr0rrrrr�staticmethodr;�
__classcell__�r*s@r+rrs���������,
���"���A9�A9�A9�A9�A9�A9�F
�
�
�
�
�c�c�c�2�2�2�$9�9�9�3�3�3�3�3������� S�S�S��"�"��\�"�"�"�"�"r,rc�l��eZdZdZ							dd�Zd�Zed	���Zd
�Zd�Z	�fd�Z
d
�Zd�Z�xZ
S)�
FluentHandlerz%
    Logging Handler for fluent.
    �	localhost�^�@FNc	���||_||_||_||_||_||_||_||_|	|_d|_	tj�|��dSr.)
�tag�_host�_port�_timeout�_verbose�_buffer_overflow_handler�_msgpack_kwargs�_nanosecond_precision�_kwargs�_senderr�Handlerr)
r#rc�host�port�timeout�verbose�buffer_overflow_handler�msgpack_kwargs�nanosecond_precision�kwargss
          r+rzFluentHandler.__init__�si�������
���
���
���
�(?��%�-���%9��"��������� � ��&�&�&�&�&r,c��tjSr.)r�FluentSenderr5s r+�getSenderClasszFluentHandler.getSenderClass�s���"�"r,c��|j�H|jd|j|j|j|j|j|j|j|j	d�|j
��|_|jS)N)rcrnrorprqrrrsrtr4)rl�getSenderInstancercrdrerfrgrhrirjrkr5s r+rzFluentHandler.sender�sk���<��1�4�1�
��H��Z��Z��
��
�(,�(E�#�3�%)�%?�
�
��,�
�
�D�L��|�r,c	�L�|���}
|
|f|||||||d�|	��S)N)rnrorprqrrrsrt)rx)r#rcrnrorprqrrrsrtru�sender_classs           r+rzzFluentHandler.getSenderInstance�sU���*�*�,�,���|��

�����$;�)�!5�

�

��

�

�
	
r,c���|�|��}|j}|�d|jrtj|j��nt
|j��|��Sr.)r/r�emit_with_timert�	EventTime�created�int)r#r1r2rls    r+�emitzFluentHandler.emit�sb���{�{�6�"�"���+���%�%���+�
%�F��V�^�,�,�,��V�^�$�$��
�
�	
r,c�N��|���		|j���t�����n%#t�����wxYw	|���dS#|���wxYwr.)�acquirer�closer
�release)r#r*s �r+r�zFluentHandler.closes|���������	�
 ���!�!�#�#�#����
�
���������
�
����������L�L�N�N�N�N�N��D�L�L�N�N�N�N���s�A�!B�"A4�4B�B$c��|Sr.r4r5s r+�	__enter__zFluentHandler.__enter__s���r,c�.�|���dSr.)r�)r#�exc_type�exc_val�exc_tbs    r+�__exit__zFluentHandler.__exit__s���
�
�����r,)r_r`raFNNF)rVrWrXrYrrx�propertyrrzr�r�r�r�r[r\s@r+r^r^�s�����������
��� $��"�'�'�'�'�0#�#�#��
�
��X�
�
�
�
�2	
�	
�	
���������������r,r^)	r>rr�fluentr�	Formatterrrmr^r4r,r+�<module>r�s�����������
�
�
�
�������h"�h"�h"�h"�h"�G�-�h"�h"�h"�Vb�b�b�b�b�G�O�b�b�b�b�br,