Package wsh.util
Class LoggerStream
- java.lang.Object
-
- java.io.OutputStream
-
- java.io.FilterOutputStream
-
- java.io.PrintStream
-
- wsh.util.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();
-
-
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 codevoid
println()
void
println(java.lang.Object x)
void
println(java.lang.String x)
-
-
-
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 Loggerlevel
- This indicates which method of the Logger should be called.
-
-
Method Detail
-
flush
public void flush()
- Specified by:
flush
in interfacejava.io.Flushable
- Overrides:
flush
in classjava.io.PrintStream
-
println
public void println()
- Overrides:
println
in classjava.io.PrintStream
-
println
public void println(java.lang.Object x)
- Overrides:
println
in classjava.io.PrintStream
-
println
public void println(java.lang.String x)
- Overrides:
println
in classjava.io.PrintStream
-
close
public void close()
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.io.PrintStream
-
checkError
public boolean checkError()
- Overrides:
checkError
in classjava.io.PrintStream
-
main
public static void main(java.lang.String[] args)
test code- Parameters:
args
- command line
-
-