org.abstracthorizon.danube.support.logging
Class LoggingOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by org.abstracthorizon.danube.support.logging.LoggingOutputStream
All Implemented Interfaces:
Closeable, Flushable
Direct Known Subclasses:
DirectionalLoggingOutputStream

public class LoggingOutputStream
extends OutputStream

Output stream for logging. An given stream is duplicated to log stream as well.

Author:
Daniel Sendula

Field Summary
protected  boolean logging
          Is logging switched flag
protected  OutputStream logOutputStream
          Log output stream
protected  OutputStream outputStream
          Original output stream
 
Constructor Summary
LoggingOutputStream(OutputStream outputStream, OutputStream logOutputStream)
          Constructor
 
Method Summary
 void close()
           
 void flush()
           
 boolean isLogging()
          Returns true if logging is on
 void setLogging(boolean logging)
          Should written bytes from output stream be copied to the output stream
 void write(byte[] b)
           
 void write(byte[] b, int off, int len)
           
 void write(int b)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

outputStream

protected OutputStream outputStream
Original output stream


logOutputStream

protected OutputStream logOutputStream
Log output stream


logging

protected boolean logging
Is logging switched flag

Constructor Detail

LoggingOutputStream

public LoggingOutputStream(OutputStream outputStream,
                           OutputStream logOutputStream)
Constructor

Parameters:
outputStream - output stream
logOutputStream - log output stream
Method Detail

setLogging

public void setLogging(boolean logging)
Should written bytes from output stream be copied to the output stream

Parameters:
logging - true if logging is on

isLogging

public boolean isLogging()
Returns true if logging is on

Returns:
true if logging is on

close

public void close()
           throws IOException
Specified by:
close in interface Closeable
Overrides:
close in class OutputStream
Throws:
IOException

flush

public void flush()
           throws IOException
Specified by:
flush in interface Flushable
Overrides:
flush in class OutputStream
Throws:
IOException

write

public void write(byte[] b)
           throws IOException
Overrides:
write in class OutputStream
Throws:
IOException

write

public void write(byte[] b,
                  int off,
                  int len)
           throws IOException
Overrides:
write in class OutputStream
Throws:
IOException

write

public void write(int b)
           throws IOException
Specified by:
write in class OutputStream
Throws:
IOException


Copyright © 2005-2009 Abstract Horizon. All Rights Reserved.