Your IP : 216.73.216.213


Current Path : /opt/alt/python37/lib64/python3.7/site-packages/twisted/logger/__pycache__/
Upload File :
Current File : //opt/alt/python37/lib64/python3.7/site-packages/twisted/logger/__pycache__/_file.cpython-37.pyc

B

:��]�	�@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�G/opt/alt/python37/lib64/python3.7/site-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�)r
r�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)N)r)�e)�
timeFormatrr�<lambda>S�z:textFileLogObserver.<locals>.formatEvent.<locals>.<lambda>)r)r	)r)rrrr
Qsz(textFileLogObserver.<locals>.formatEvent)r
)rrr
r)rr�textFileLogObserver@sr"N)rZzope.interfacerZtwisted.python.compatrrZ	_observerr�_formatrrr	�objectr
r"rrrr�<module>s,