Package com.google.api.client.util
Class LoggingInputStream
- java.lang.Object
-
- java.io.InputStream
-
- java.io.FilterInputStream
-
- 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 aLoggingByteArrayOutputStream.- Since:
- 1.9
- Author:
- Yaniv Inbar
-
-
Field Summary
-
Fields inherited from class java.io.FilterInputStream
in
-
-
Constructor Summary
Constructors Constructor Description LoggingInputStream(InputStream inputStream, Logger logger, Level loggingLevel, int contentLoggingLimit)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()LoggingByteArrayOutputStreamgetLogStream()Returns the log stream.intread()intread(byte[] b, int off, int len)-
Methods inherited from class java.io.FilterInputStream
available, mark, markSupported, read, reset, skip
-
-
-
-
Constructor Detail
-
LoggingInputStream
public LoggingInputStream(InputStream inputStream, Logger logger, Level loggingLevel, int contentLoggingLimit)
- Parameters:
inputStream- input stream to forward all reads tologger- loggerloggingLevel- logging levelcontentLoggingLimit- maximum number of bytes to log (may be0to avoid logging content)
-
-
Method Detail
-
read
public int read() throws IOException- Overrides:
readin classFilterInputStream- Throws:
IOException
-
read
public int read(byte[] b, int off, int len) throws IOException- Overrides:
readin classFilterInputStream- Throws:
IOException
-
close
public void close() throws IOException- Specified by:
closein interfaceCloseable- Overrides:
closein classFilterInputStream- Throws:
IOException
-
getLogStream
public final LoggingByteArrayOutputStream getLogStream()
Returns the log stream.
-
-