com.google.api.client.util
Class LoggingOutputStream

java.lang.Object
  extended by java.io.OutputStream
      extended by java.io.FilterOutputStream
          extended by com.google.api.client.util.LoggingOutputStream
All Implemented Interfaces:
Closeable, Flushable

public class LoggingOutputStream
extends FilterOutputStream

Thread-safe output stream wrapper that forwards all writes to a given output stream, while logging all writes to a LoggingByteArrayOutputStream.

Since:
1.9
Author:
Yaniv Inbar

Field Summary
 
Fields inherited from class java.io.FilterOutputStream
out
 
Constructor Summary
LoggingOutputStream(OutputStream outputStream, Logger logger, Level loggingLevel, int contentLoggingLimit)
           
 
Method Summary
 void close()
           
 LoggingByteArrayOutputStream getLogStream()
          Returns the log stream.
 void write(byte[] b, int off, int len)
           
 void write(int b)
           
 
Methods inherited from class java.io.FilterOutputStream
flush, write
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LoggingOutputStream

public LoggingOutputStream(OutputStream outputStream,
                           Logger logger,
                           Level loggingLevel,
                           int contentLoggingLimit)
Parameters:
outputStream - output stream to forward all writes to
logger - logger
loggingLevel - logging level
contentLoggingLimit - maximum number of bytes to log (may be 0 to avoid logging content)
Method Detail

write

public void write(int b)
           throws IOException
Overrides:
write in class FilterOutputStream
Throws:
IOException

write

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

close

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

getLogStream

public final LoggingByteArrayOutputStream getLogStream()
Returns the log stream.



Copyright © 2011-2012 Google. All Rights Reserved.