OutputStream
are buffered until a newline character is encountered, or a flush() is called.
Extend to specify the log method that the message should be invoked. eg:
setOutputStream( new LoggerAwareOutputStream( getLogger() ) {
protected void logMessage( String message )
{
if ( m_logger.isDebugEnabled() )
{
m_logger.debug( message );
}
}
} );
| Modifier and Type | Field and Description |
|---|---|
| private final ByteArrayOutputStream | bos
Message buffer |
| protected final Logger |
| Access | Constructor and Description |
|---|---|
| public | LoggerAwareOutputStream(Logger
logger this output stream should use logger)Constructor, creates instance of class. |
| Modifier and Type | Method and Description |
|---|---|
| public void | close()
Overrides java. Implements java. |
| public void | flush()
Overrides java. Implements java. |
| protected abstract void | |
| public void | write(int
character to write b)Implements abstract java. |
| bos | back to summary |
|---|---|
| private final ByteArrayOutputStream bos Message buffer | |
| m_logger | back to summary |
|---|---|
| protected final Logger m_logger
| |
| LoggerAwareOutputStream | back to summary |
|---|---|
| public LoggerAwareOutputStream(Logger logger) Constructor, creates instance of class.
| |
| close | back to summary |
|---|---|
| public void close() throws IOException Overrides java. Implements java. Purposely flushes the stream, but doesn't close anything since the logger is managed by another class.
| |
| flush | back to summary |
|---|---|
| public void flush() throws IOException Overrides java. Implements java. Flushes this output stream, writing any buffered content to the log
| |
| logMessage | back to summary |
|---|---|
| protected abstract void logMessage(String message) Writes the message to the log. Subclasses should override this method to send the message to the log level they require.
| |
| write | back to summary |
|---|---|
| public void write(int b) throws IOException Implements abstract java. Writes a byte to the internal buffer. If a newline character is encountered, then the buffer is sent to the logger.
| |