de.qfs.lib.log
Class LogStream
java.lang.Object
|
+--java.io.OutputStream
|
+--de.qfs.lib.log.LogStream
- public class LogStream
- extends java.io.OutputStream
This stream logs everything written to it. It can be useful to pipe errors
and debugging output from third party packages to the logging
facilities.
A LogStream collects its input until it encouters either a LineFeed, a
CarriageReturn or a CarriageReturn followed by a LineFeed character. It
will then log the buffered line, using the Log level, class and method
names passed to its constructor. An explicit call to flush will log the
characters collected so far.
No empty log messages will be generated.
- Version:
- $Revision: 1.7 $
- Author:
- Gregor Schmid
Constructor Summary |
LogStream(int level,
java.lang.String clazz,
java.lang.String method)
Create a new LogStream. |
Method Summary |
void |
close()
Close the LogStream. |
void |
flush()
Flush the LogStream, logging the current message. |
void |
write(int b)
Write one byte to the LogStream. |
Methods inherited from class java.io.OutputStream |
write, write |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
LogStream
public LogStream(int level,
java.lang.String clazz,
java.lang.String method)
- Create a new LogStream.
- Parameters:
level
- The log level for the logStream.clazz
- The class name for the logged messages.method
- The method name for the logged messages.- See Also:
Log
close
public void close()
- Close the LogStream.
- Overrides:
close
in class java.io.OutputStream
flush
public void flush()
throws java.io.IOException
- Flush the LogStream, logging the current message.
- Overrides:
flush
in class java.io.OutputStream
- Throws:
java.io.IOException
- If the LogStream has been closed.
write
public void write(int b)
throws java.io.IOException
- Write one byte to the LogStream.
- Overrides:
write
in class java.io.OutputStream
- Parameters:
b
- The byte to write (only the lower 8 bits of the int
are used).- Throws:
java.io.IOException
- If the LogStream has been closed.