com.google.api.client.util
Class LoggingInputStream

java.lang.Object
  extended by java.io.InputStream
      extended by java.io.FilterInputStream
          extended by com.google.api.client.util.LoggingInputStream
All Implemented Interfaces:
Closeable

public class LoggingInputStream
extends FilterInputStream

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

Since:
1.9
Author:
Yaniv Inbar

Field Summary
 
Fields inherited from class java.io.FilterInputStream
in
 
Constructor Summary
LoggingInputStream(InputStream inputStream, Logger logger, Level loggingLevel, int contentLoggingLimit)
           
 
Method Summary
 void close()
           
 LoggingByteArrayOutputStream getLogStream()
          Returns the log stream.
 int read()
           
 int read(byte[] b, int off, int len)
           
 
Methods inherited from class java.io.FilterInputStream
available, mark, markSupported, read, reset, skip
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

LoggingInputStream

public LoggingInputStream(InputStream inputStream,
                          Logger logger,
                          Level loggingLevel,
                          int contentLoggingLimit)
Parameters:
inputStream - input stream to forward all reads to
logger - logger
loggingLevel - logging level
contentLoggingLimit - maximum number of bytes to log (may be 0 to avoid logging content)
Method Detail

read

public int read()
         throws IOException
Overrides:
read in class FilterInputStream
Throws:
IOException

read

public int read(byte[] b,
                int off,
                int len)
         throws IOException
Overrides:
read in class FilterInputStream
Throws:
IOException

close

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

getLogStream

public final LoggingByteArrayOutputStream getLogStream()
Returns the log stream.



Copyright © 2011-2012 Google. All Rights Reserved.