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:
java.io.Closeable,java.lang.AutoCloseable
public class LoggingInputStream extends java.io.FilterInputStreamThread-safe input stream wrapper that forwards all reads to a given input stream, while logging all reads to aLoggingByteArrayOutputStream.- Since:
- 1.9
-
-
Field Summary
Fields Modifier and Type Field Description private LoggingByteArrayOutputStreamlogStreamLog stream.
-
Constructor Summary
Constructors Constructor Description LoggingInputStream(java.io.InputStream inputStream, java.util.logging.Logger logger, java.util.logging.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)
-
-
-
Field Detail
-
logStream
private final LoggingByteArrayOutputStream logStream
Log stream.
-
-
Constructor Detail
-
LoggingInputStream
public LoggingInputStream(java.io.InputStream inputStream, java.util.logging.Logger logger, java.util.logging.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 java.io.IOException- Overrides:
readin classjava.io.FilterInputStream- Throws:
java.io.IOException
-
read
public int read(byte[] b, int off, int len) throws java.io.IOException- Overrides:
readin classjava.io.FilterInputStream- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Overrides:
closein classjava.io.FilterInputStream- Throws:
java.io.IOException
-
getLogStream
public final LoggingByteArrayOutputStream getLogStream()
Returns the log stream.
-
-