Class LoggingOutputStream

java.lang.Object
java.io.OutputStream
sonia.scm.logging.LoggingOutputStream
All Implemented Interfaces:
Closeable, Flushable, AutoCloseable

public class LoggingOutputStream extends OutputStream
An OutputStream that flushes out to a Logger. Based on LoggingOutputStream by Jim Moore
  • Field Details

  • Constructor Details

    • LoggingOutputStream

      public LoggingOutputStream(org.slf4j.Logger logger, int level) throws IllegalArgumentException
      Creates the LoggingOutputStream to flush to the given Logger.
      Parameters:
      logger - - the Logger to write to
      level - - the Level to use when writing to the Logger
      Throws:
      IllegalArgumentException - if cat == null or priority == null
  • Method Details

    • close

      public void close()
      Closes this output stream and releases any system resources associated with this stream. The general contract of close is that it closes the output stream. A closed stream cannot perform output operations and cannot be reopened.
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Overrides:
      close in class OutputStream
    • flush

      public void flush()
      Flushes this output stream and forces any buffered output bytes to be written out. The general contract of flush is that calling it is an indication that, if any bytes previously written have been buffered by the implementation of the output stream, such bytes should immediately be written to their intended destination.
      Specified by:
      flush in interface Flushable
      Overrides:
      flush in class OutputStream
    • log

      public void log(String message)
    • write

      public void write(int b) throws IOException
      Writes the specified byte to this output stream. The general contract for write is that one byte is written to the output stream. The byte to be written is the eight low-order bits of the argument b. The 24 high-order bits of b are ignored.
      Specified by:
      write in class OutputStream
      Parameters:
      b - the byte to write
      Throws:
      IOException