ϪftdZddlZddlmZmZmZddlmZddlm Z ddl m Z ddl m Z dd lmZGd d Zy) z File-like object that logs. N)AnyStrIterableOptional) NamedConstant)Version)deprecatedProperty)LogLevel)Loggerc eZdZdZdZeedddddZejdZe jdfd e d e d e ed dfd Zed efdZed efdZed efdZeddZed efdZddZddZd efdZd efdZded dfdZdeed dfdZde d dfdZ!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. rTwistedc|jSN _softspaceselfs 4/usr/lib/python3/dist-packages/twisted/logger/_io.py softspacezLoggingFile.softspace!s c||_yrr)rvalues rrzLoggingFile.softspace%s rNloggerlevelencodingreturnc||_||_|tj|_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()}. NF)rlogsysgetdefaultencoding _encoding_buffer_closed)rrrrs r__init__zLoggingFile.__init__)s=    335DN%DN  rc|jS)zm Read-only property. Is the file closed? @return: true if closed, otherwise false. r'rs rclosedzLoggingFile.closed@s||rc|jS)zU Read-only property. File encoding. @return: an encoding. )r%rs rrzLoggingFile.encodingIs~~rcy)zG Read-only property. File mode. @return: "w" wrs rmodezLoggingFile.modeRsrcy)z_ Read-only property. Types of newlines encountered. @return: L{None} Nr/rs rnewlineszLoggingFile.newlines[srcdj|jj|jj|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" namespacernamers rr8zLoggingFile.nameds<"" NN # # HH   JJOO  rcd|_y)zD Close this file so it can no longer be written to. TNr*rs rclosezLoggingFile.closers  rcy)z3 No-op; this file does not buffer. Nr/rs rflushzLoggingFile.flushxs rcy)zp Returns an invalid file descriptor, since this is not backed by an FD. @return: C{-1} r/rs rfilenozLoggingFile.fileno~s rcy)zK A L{LoggingFile} is not a TTY. @return: C{False} Fr/rs risattyzLoggingFile.isattys rmessagecF|jr tdt|tr|j |j }n|}|j |zjd}|d|_|dd}|D]*}|jj|jd|,y)zW Log the given message. @param message: The message to write. zI/O operation on closed file r>rz{log_io})r4log_ioN) r' ValueError isinstancebytesdecoder%r&splitr"emitr)rrBtextlineslines rwritezLoggingFile.writes <<;< < gu %>>$..1DD$++D1Ry a  FD HHMM$**ZM E FrrMc4|D]}|j|y)zj Log each of the given lines as a separate message. @param lines: Data to write. N)rO)rrMrNs r writelineszLoggingFile.writeliness  D JJt  rargsctd)zW Template for unsupported operations. @param args: Arguments. zunsupported operation)OSError)rrRs r _unsupportedzLoggingFile._unsupporteds -..r)rN)*r6 __module__ __qualname____doc__rrrrsetterr infor rrstrr(propertyboolr+rr0r2r8r:r<intr?rArrOrrQobjectrUreadnextreadline readlines xreadlinesseektelltruncater/rrr r sJ 2q!456  (}}"& 3-   .#c  c      FVFF* 0T/&/T/ D DHIJ D DHrr )rXr#typingrrr constantlyr incrementalrtwisted.python.deprecater_levelsr _loggerr r r/rrrns0  --$7ggr