Class LogWriter

  • All Implemented Interfaces:
    java.io.Closeable, java.io.Flushable, java.lang.Appendable, java.lang.AutoCloseable

    public class LogWriter
    extends java.io.Writer
    The LogWriter is a simple Writer which writes lines of data to a given SLF4J Logger. Data is gathered in an internal buffer until the flush() method is called or until a CR or LF character is encountered in the data to be written.
    • Field Summary

      • Fields inherited from class java.io.Writer

        lock
    • Constructor Summary

      Constructors 
      Constructor Description
      LogWriter​(org.slf4j.Logger logger)
      Creates a writer based on the given logger.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void close()
      Just calls flush()
      void flush()
      Writes any data conained in the buffer to the logger as an error message.
      void write​(char[] cbuf, int off, int len)
      Writes the indicated characters to the internal buffer, flushing the buffer on any occurrence of a CR of LF.
      void write​(int c)
      Writes the character to the internal buffer unless the character is a CR or LF in which case the buffer is written to the logger as an error message.
      • Methods inherited from class java.io.Writer

        append, append, append, nullWriter, write, write, write
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • LogWriter

        public LogWriter​(org.slf4j.Logger logger)
        Creates a writer based on the given logger.
        Parameters:
        logger - the logger
    • Method Detail

      • write

        public void write​(int c)
        Writes the character to the internal buffer unless the character is a CR or LF in which case the buffer is written to the logger as an error message.
        Overrides:
        write in class java.io.Writer
      • write

        public void write​(char[] cbuf,
                          int off,
                          int len)
        Writes the indicated characters to the internal buffer, flushing the buffer on any occurrence of a CR of LF.
        Specified by:
        write in class java.io.Writer
      • flush

        public void flush()
        Writes any data conained in the buffer to the logger as an error message.
        Specified by:
        flush in interface java.io.Flushable
        Specified by:
        flush in class java.io.Writer
      • close

        public void close()
        Just calls flush()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Specified by:
        close in class java.io.Writer