Package com.google.api.client.util
Class LoggingOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- java.io.FilterOutputStream
-
- com.google.api.client.util.LoggingOutputStream
-
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
public class LoggingOutputStream extends FilterOutputStream
Thread-safe output stream wrapper that forwards all writes to a given output stream, while logging all writes to aLoggingByteArrayOutputStream
.- Since:
- 1.9
- Author:
- Yaniv Inbar
-
-
Field Summary
-
Fields inherited from class java.io.FilterOutputStream
out
-
-
Constructor Summary
Constructors Constructor Description LoggingOutputStream(OutputStream outputStream, Logger logger, Level loggingLevel, int contentLoggingLimit)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description 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
-
-
-
-
Constructor Detail
-
LoggingOutputStream
public LoggingOutputStream(OutputStream outputStream, Logger logger, Level loggingLevel, int contentLoggingLimit)
- Parameters:
outputStream
- output stream to forward all writes tologger
- loggerloggingLevel
- logging levelcontentLoggingLimit
- maximum number of bytes to log (may be0
to avoid logging content)
-
-
Method Detail
-
write
public void write(int b) throws IOException
- Overrides:
write
in classFilterOutputStream
- Throws:
IOException
-
write
public void write(byte[] b, int off, int len) throws IOException
- Overrides:
write
in classFilterOutputStream
- Throws:
IOException
-
close
public void close() throws IOException
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classFilterOutputStream
- Throws:
IOException
-
getLogStream
public final LoggingByteArrayOutputStream getLogStream()
Returns the log stream.
-
-