HEX
Server: Apache/2.4.52 (Ubuntu)
System: Linux spn-python 5.15.0-89-generic #99-Ubuntu SMP Mon Oct 30 20:42:41 UTC 2023 x86_64
User: arjun (1000)
PHP: 8.1.2-1ubuntu2.20
Disabled: NONE
Upload Files
File: //lib/python3/dist-packages/twisted/logger/__pycache__/_file.cpython-38.pyc
U

�b!	�@s�dZddlmZmZmZmZddlmZddlm	Z	ddl
mZmZm
Z
ddlmZmZee�Gdd	�d	��Ze
feeeeed
�dd�Zd
S)z
File log observer.
�)�IO�Any�Callable�Optional)�implementer)�ioType�)�formatEventAsClassicLogText�
formatTime�timeFormatRFC3339)�ILogObserver�LogEventc@sDeZdZdZeeeegee	fdd�dd�Z
edd�dd�ZdS)	�FileLogObserverz9
    Log observer that writes to a file-like object.
    N)�outFile�formatEvent�returncCs*t|�tk	rd|_nd|_||_||_dS)z�
        @param outFile: A file-like object.  Ideally one should be passed which
            accepts text data.  Otherwise, UTF-8 L{bytes} will be used.
        @param formatEvent: A callable that formats an event.
        zutf-8N)r�str�	_encoding�_outFiler)�selfrr�r�6/usr/lib/python3/dist-packages/twisted/logger/_file.py�__init__s
zFileLogObserver.__init__��eventrcCsH|�|�}|rD|jdkr&|j�|�n|j�|�|j��|j��dS)zG
        Write event to file.

        @param event: An event.
        N)rrr�write�encode�flush)rr�textrrr�__call__(s

zFileLogObserver.__call__)�__name__�
__module__�__qualname__�__doc__rrrr
rrrrrrrrrs�r)r�
timeFormatrcs"tttd��fdd�}t||�S)a�
    Create a L{FileLogObserver} that emits text to a specified (writable)
    file-like object.

    @param outFile: A file-like object.  Ideally one should be passed which
        accepts text data.  Otherwise, UTF-8 L{bytes} will be used.
    @param timeFormat: The format to use when adding timestamp prefixes to
        logged events.  If L{None}, or for events with no C{"log_timestamp"}
        key, the default timestamp prefix of C{"-"} is used.

    @return: A file log observer.
    rcst|�fdd�d�S)Ncs
t|��S)N�r
)�e�r$rr�<lambda>J�z:textFileLogObserver.<locals>.formatEvent.<locals>.<lambda>r%)r	)rr'rrrHs
�z(textFileLogObserver.<locals>.formatEvent)r
rrr)rr$rrr'r�textFileLogObserver8sr*N)r#�typingrrrr�zope.interfacer�twisted.python.compatr�_formatr	r
r�_interfacesrr
rrr*rrrr�<module>s&��