
    \d                     |    d Z ddlZddlmZmZmZ ddlmZ ddlm	Z	 ddl
mZ ddlmZ dd	lmZ  G d
 d          ZdS )z
File-like object that logs.
    N)AnyStrIterableOptional)NamedConstant)Version)deprecatedProperty   )LogLevel)Loggerc            	          e Zd ZdZdZ e edddd                    d             Zej        d             Ze	j
        dfd	ed
edee         ddfdZedefd            Zedefd            Zedefd            Zedd            Zedefd            ZddZddZdefdZdefdZdeddfdZdee         ddfdZde ddfdZ!e!Z"e!Z#e!Z$e!Z%e!Z&e!Z'e!Z(e!Z)dS )LoggingFileac  
    File-like object that turns C{write()} calls into logging events.

    Note that because event formats are L{str}, C{bytes} received via C{write()}
    are converted to C{str}, which is the opposite of what C{file} does.

    @ivar softspace: Attribute to make this class more file-like under Python 2;
        value is zero or one.  Do not use.
    r   Twisted      c                     | j         S N
_softspaceselfs    2lib/python3.11/site-packages/twisted/logger/_io.py	softspacezLoggingFile.softspace!   s
        c                     || _         d S r   r   )r   values     r   r   zLoggingFile.softspace%   s    r   Nloggerlevelencodingreturnc                     || _         || _        |t          j                    | _        n|| _        d| _        d| _        dS )a  
        @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()}.
        N F)r   logsysgetdefaultencoding	_encoding_buffer_closed)r   r   r   r   s       r   __init__zLoggingFile.__init__)   sC     
 355DNN%DNr   c                     | j         S )zm
        Read-only property.  Is the file closed?

        @return: true if closed, otherwise false.
        r'   r   s    r   closedzLoggingFile.closed@   s     |r   c                     | j         S )zU
        Read-only property.   File encoding.

        @return: an encoding.
        )r%   r   s    r   r   zLoggingFile.encodingI   s     ~r   c                     dS )zG
        Read-only property.  File mode.

        @return: "w"
        w r   s    r   modezLoggingFile.modeR   s	     sr   c                     dS )z_
        Read-only property.  Types of newlines encountered.

        @return: L{None}
        Nr/   r   s    r   newlineszLoggingFile.newlines[   s	     tr   c                 l    d                     | j        j        | j        j        | j        j                  S )z
        The name of this file; a repr-style string giving information about its
        namespace.

        @return: A file name.
        z
<{} {}#{}>)format	__class____name__r"   	namespacer   namer   s    r   r8   zLoggingFile.named   s3     ""N#HJO
 
 	
r   c                     d| _         dS )zD
        Close this file so it can no longer be written to.
        TNr*   r   s    r   closezLoggingFile.closer   s     r   c                     dS )z3
        No-op; this file does not buffer.
        Nr/   r   s    r   flushzLoggingFile.flushx   s	     	r   c                     dS )zp
        Returns an invalid file descriptor, since this is not backed by an FD.

        @return: C{-1}
        r/   r   s    r   filenozLoggingFile.fileno~   s	     rr   c                     dS )zK
        A L{LoggingFile} is not a TTY.

        @return: C{False}
        Fr/   r   s    r   isattyzLoggingFile.isatty   s	     ur   messagec                 L   | j         rt          d          t          |t                    r|                    | j                  }n|}| j        |z                       d          }|d         | _        |dd         }|D ]$}| j        	                    | j
        d|           %dS )zW
        Log the given message.

        @param message: The message to write.
        zI/O operation on closed file
r>   r   z{log_io})r4   log_ioN)r'   
ValueError
isinstancebytesdecoder%   r&   splitr"   emitr   )r   rB   textlineslines        r   writezLoggingFile.write   s     < 	=;<<<gu%% 	>>$.11DDD$++D11Ryad 	F 	FDHMM$*ZMEEEE	F 	Fr   rM   c                 :    |D ]}|                      |           dS )zj
        Log each of the given lines as a separate message.

        @param lines: Data to write.
        N)rO   )r   rM   rN   s      r   
writelineszLoggingFile.writelines   s2      	 	DJJt	 	r   argsc                      t          d          )zW
        Template for unsupported operations.

        @param args: Arguments.
        zunsupported operation)OSError)r   rR   s     r   _unsupportedzLoggingFile._unsupported   s     -...r   )r   N)*r6   
__module____qualname____doc__r   r   r   r   setterr
   infor   r   r   strr(   propertyboolr+   r   r0   r2   r8   r:   r<   intr?   rA   r   rO   r   rQ   objectrU   readnextreadline	readlines
xreadlinesseektelltruncater/   r   r   r   r      su         J	2q!4455  65        (}"&	   3-	
 
   .     X #    X c    X    X 
c 
 
 
 X
              FV F F F F F* 0 T    /& /T / / / / DDHIJDDHHHr   r   )rX   r#   typingr   r   r   
constantlyr   incrementalr   twisted.python.deprecater   _levelsr
   _loggerr   r   r/   r   r   <module>rn      s   
  


 - - - - - - - - - - $ $ $ $ $ $       7 7 7 7 7 7            g g g g g g g g g gr   