Package wsh.util

Class LoggerStream

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

    public class LoggerStream
    extends java.io.PrintStream
    Wrap a Logger as a PrintStream. Useful mainly for porting code that previously logged to a System PrintStream or to a proxy. Calling LoggerStream.println() will call Logger.info() for Level.INFO. A call to flush() or to a println() method will flush previously written text, and complete a call to Logger. You may be surprised by extra newlines, if you call print("\n") and flush() instead of println();
    • Field Summary

      • Fields inherited from class java.io.FilterOutputStream

        out
    • Constructor Summary

      Constructors 
      Constructor Description
      LoggerStream​(java.util.logging.Logger logger, java.util.logging.Level level)
      Wrap a Logger as a PrintStream .
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      boolean checkError()  
      void close()  
      void flush()  
      static void main​(java.lang.String[] args)
      test code
      void println()  
      void println​(java.lang.Object x)  
      void println​(java.lang.String x)  
      • Methods inherited from class java.io.PrintStream

        append, append, append, clearError, format, format, print, print, print, print, print, print, print, print, print, printf, printf, println, println, println, println, println, println, println, setError, write, write
      • Methods inherited from class java.io.FilterOutputStream

        write
      • Methods inherited from class java.io.OutputStream

        nullOutputStream
      • Methods inherited from class java.lang.Object

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

      • LoggerStream

        public LoggerStream​(java.util.logging.Logger logger,
                            java.util.logging.Level level)
        Wrap a Logger as a PrintStream .
        Parameters:
        logger - Everything written to this PrintStream will be passed to the appropriate method of the Logger
        level - This indicates which method of the Logger should be called.
    • Method Detail

      • flush

        public void flush()
        Specified by:
        flush in interface java.io.Flushable
        Overrides:
        flush in class java.io.PrintStream
      • println

        public void println()
        Overrides:
        println in class java.io.PrintStream
      • println

        public void println​(java.lang.Object x)
        Overrides:
        println in class java.io.PrintStream
      • println

        public void println​(java.lang.String x)
        Overrides:
        println in class java.io.PrintStream
      • close

        public void close()
        Specified by:
        close in interface java.lang.AutoCloseable
        Specified by:
        close in interface java.io.Closeable
        Overrides:
        close in class java.io.PrintStream
      • checkError

        public boolean checkError()
        Overrides:
        checkError in class java.io.PrintStream
      • main

        public static void main​(java.lang.String[] args)
        test code
        Parameters:
        args - command line