Your IP : 216.73.216.213
B
:��]k � @ s, d Z ddlZddlmZ G dd� de�ZdS )z
File-like object that logs.
� N� )�LogLevelc @ s� e Zd ZdZdZejdfdd�Zedd� �Z edd � �Z
ed
d� �Zedd
� �Zedd� �Z
dd� Zdd� Zdd� Zdd� Zdd� Zdd� Zdd� ZeZeZeZeZeZeZeZeZdS )�LoggingFilean
File-like object that turns C{write()} calls into logging events.
Note that because event formats are C{unicode}, C{bytes} received via
C{write()} are converted to C{unicode}, which is the opposite of what
C{file} does.
@ivar softspace: File-like L{'softspace' attribute <file.softspace>}; zero
or one.
@type softspace: L{int}
r Nc C s6 || _ || _|dkr t�� | _n|| _d| _d| _dS )at
@param logger: the logger to log through.
@param level: the log level to emit events with.
@param encoding: The encoding to expect when receiving bytes via
C{write()}. If L{None}, use C{sys.getdefaultencoding()}.
@type encoding: L{str}
@param log: The logger to send events to.
@type log: L{Logger}
N� F)�level�log�sys�getdefaultencoding� _encoding�_buffer�_closed)�self�loggerr �encoding� r �E/opt/alt/python37/lib64/python3.7/site-packages/twisted/logger/_io.py�__init__ s
zLoggingFile.__init__c C s | j S )z�
Read-only property. Is the file closed?
@return: true if closed, otherwise false.
@rtype: L{bool}
)r )r
r r r �closed8 s zLoggingFile.closedc C s | j S )zl
Read-only property. File encoding.
@return: an encoding.
@rtype: L{str}
)r
)r
r r r r C s zLoggingFile.encodingc C s dS )z^
Read-only property. File mode.
@return: "w"
@rtype: L{str}
�wr )r
r r r �modeN s zLoggingFile.modec C s dS )zw
Read-only property. Types of newlines encountered.
@return: L{None}
@rtype: L{None}
Nr )r
r r r �newlinesY s zLoggingFile.newlinesc C s d� | jj| jj| jj�S )z�
The name of this file; a repr-style string giving information about its
namespace.
@return: A file name.
@rtype: L{str}
z
<{0} {1}#{2}>)�format� __class__�__name__r � namespacer �name)r
r r r r d s
zLoggingFile.namec C s
d| _ dS )zD
Close this file so it can no longer be written to.
TN)r )r
r r r �closev s zLoggingFile.closec C s dS )z3
No-op; this file does not buffer.
Nr )r
r r r �flush} s zLoggingFile.flushc C s dS )z�
Returns an invalid file descriptor, since this is not backed by an FD.
@return: C{-1}
@rtype: L{int}
���r )r
r r r �fileno� s zLoggingFile.filenoc C s dS )zc
A L{LoggingFile} is not a TTY.
@return: C{False}
@rtype: L{bool}
Fr )r
r r r �isatty� s zLoggingFile.isattyc C sp | j rtd��t|t�r$|�| j�}| j| �d�}|d | _|dd� }x |D ]}| jj | j
d|d� qPW dS )z�
Log the given message.
@param string: Data to write.
@type string: L{bytes} in this file's preferred encoding or L{unicode}
zI/O operation on closed file�
r r z{log_io})r Zlog_ioN)r �
ValueError�
isinstance�bytes�decoder
r �splitr �emitr )r
�string�lines�liner r r �write� s
zLoggingFile.writec C s x|D ]}| � |� qW dS )z�
Log each of the given lines as a separate message.
@param lines: Data to write.
@type lines: iterable of L{unicode} or L{bytes} in this file's
declared encoding
N)r+ )r
r) r* r r r �
writelines� s
zLoggingFile.writelinesc G s t d��dS )z~
Template for unsupported operations.
@param args: Arguments.
@type args: tuple of L{object}
zunsupported operationN)�IOError)r
�argsr r r �_unsupported� s zLoggingFile._unsupported)r �
__module__�__qualname__�__doc__� softspacer �infor �propertyr r r r r r r r r r+ r, r/ �read�next�readline� readlinesZ
xreadlines�seek�tell�truncater r r r r s.
r )r2 r Z_levelsr �objectr r r r r �<module> s