
    Vh                     t    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y)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)y)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    B/home/dcms/DCMS/lib/python3.12/site-packages/twisted/logger/_io.py	softspacezLoggingFile.softspace!   s        c                     || _         y r   r   )r   values     r   r   zLoggingFile.softspace%   s	    r   Nloggerlevelencodingreturnc                     || _         || _        |t        j                         | _        n|| _        d| _        d| _        y)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__)   s=     
 335DN%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                      y)zG
        Read-only property.  File mode.

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

        @return: L{None}
        Nr/   r   s    r   newlineszLoggingFile.newlines[   s     r   c                     dj                  | 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   s<     ""NN##HHJJOO
 	
r   c                     d| _         y)zD
        Close this file so it can no longer be written to.
        TNr*   r   s    r   closezLoggingFile.closer   s     r   c                      y)z3
        No-op; this file does not buffer.
        Nr/   r   s    r   flushzLoggingFile.flushx   s     	r   c                      y)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     r   c                      y)zK
        A L{LoggingFile} is not a TTY.

        @return: C{False}
        Fr/   r   s    r   isattyzLoggingFile.isatty   s     r   messagec                 F   | j                   rt        d      t        |t              r|j	                  | j
                        }n|}| j                  |z   j                  d      }|d   | _        |dd }|D ]*  }| j                  j                  | j                  d|       , y)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%>>$..1DD$++D1Rya 	FDHHMM$**ZME	Fr   rM   c                 4    |D ]  }| j                  |        y)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   s      	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      s    J	2q!45 6      (}}"&	  3-	
 
.    #   c     
c 
 
  FV F F* 0 T /& /T / DDHIJDDHr   r   )rX   r#   typingr   r   r   
constantlyr   incrementalr   twisted.python.deprecater   _levelsr
   _loggerr   r   r/   r   r   <module>rn      s0   
  - - $  7  g gr   