HEX
Server: Apache
System: Linux scp1.abinfocom.com 5.4.0-216-generic #236-Ubuntu SMP Fri Apr 11 19:53:21 UTC 2025 x86_64
User: confeduphaar (1010)
PHP: 8.1.33
Disabled: exec,passthru,shell_exec,system
Upload Files
File: //proc/self/root/usr/lib/python3/dist-packages/twisted/logger/__pycache__/_file.cpython-38.pyc
U


W[�	�@sxdZddlmZddlmZmZddlmZddlm	Z	ddlm
Z
ddlmZee�Gd	d
�d
e��Z
e
fdd�Zd
S)z
File log observer.
�)�implementer)�ioType�unicode�)�ILogObserver��
formatTime)�timeFormatRFC3339��formatEventAsClassicLogTextc@s eZdZdZdd�Zdd�ZdS)�FileLogObserverz9
    Log observer that writes to a file-like object.
    cCs*t|�tk	rd|_nd|_||_||_dS)a�
        @param outFile: A file-like object.  Ideally one should be passed which
            accepts L{unicode} data.  Otherwise, UTF-8 L{bytes} will be used.
        @type outFile: L{io.IOBase}

        @param formatEvent: A callable that formats an event.
        @type formatEvent: L{callable} that takes an C{event} argument and
            returns a formatted event as L{unicode}.
        zutf-8N)rr�	_encoding�_outFile�formatEvent)�self�outFiler�r�6/usr/lib/python3/dist-packages/twisted/logger/_file.py�__init__s

zFileLogObserver.__init__cCsJ|�|�}|dkrd}|jdk	r,|�|j�}|rF|j�|�|j��dS)zd
        Write event to file.

        @param event: An event.
        @type event: L{dict}
        N�)rr
�encoder�write�flush)r�event�textrrr�__call__+s

zFileLogObserver.__call__N)�__name__�
__module__�__qualname__�__doc__rrrrrrrsrcs�fdd�}t||�S)aa
    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 L{unicode} data.  Otherwise, UTF-8 L{bytes} will be used.
    @type outFile: L{io.IOBase}

    @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{u"-"} is used.
    @type timeFormat: L{unicode} or L{None}

    @return: A file log observer.
    @rtype: L{FileLogObserver}
    cst|�fdd�d�S)Ncs
t|��S)Nr)�e��
timeFormatrr�<lambda>S�z:textFileLogObserver.<locals>.formatEvent.<locals>.<lambda>rr
)rr!rrrQs
�z(textFileLogObserver.<locals>.formatEvent)r)rr"rrr!r�textFileLogObserver@sr%N)rZzope.interfacerZtwisted.python.compatrrZ	_observerrZ_formatrr	r�objectrr%rrrr�<module>s,