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:
java.io.Closeable
,java.io.Flushable
,java.lang.AutoCloseable
public class LoggingOutputStream extends java.io.FilterOutputStream
Thread-safe output stream wrapper that forwards all writes to a given output stream, while logging all writes to aLoggingByteArrayOutputStream
.- Since:
- 1.9
-
-
Field Summary
Fields Modifier and Type Field Description private LoggingByteArrayOutputStream
logStream
Log stream.
-
Constructor Summary
Constructors Constructor Description LoggingOutputStream(java.io.OutputStream outputStream, 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 void
close()
LoggingByteArrayOutputStream
getLogStream()
Returns the log stream.void
write(byte[] b, int off, int len)
void
write(int b)
-
-
-
Field Detail
-
logStream
private final LoggingByteArrayOutputStream logStream
Log stream.
-
-
Constructor Detail
-
LoggingOutputStream
public LoggingOutputStream(java.io.OutputStream outputStream, java.util.logging.Logger logger, java.util.logging.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 java.io.IOException
- Overrides:
write
in classjava.io.FilterOutputStream
- Throws:
java.io.IOException
-
write
public void write(byte[] b, int off, int len) throws java.io.IOException
- Overrides:
write
in classjava.io.FilterOutputStream
- Throws:
java.io.IOException
-
close
public void close() throws java.io.IOException
- Specified by:
close
in interfacejava.lang.AutoCloseable
- Specified by:
close
in interfacejava.io.Closeable
- Overrides:
close
in classjava.io.FilterOutputStream
- Throws:
java.io.IOException
-
getLogStream
public final LoggingByteArrayOutputStream getLogStream()
Returns the log stream.
-
-