Class LoggingOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- dev.aherscu.qa.testing.utils.logging.LoggingOutputStream
-
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
public class LoggingOutputStream extends OutputStream
Logs the information passing through an output stream at trace level. The information will be logged uponclose()
.- Author:
- aherscu
- See Also:
Logger
-
-
Constructor Summary
Constructors Constructor Description LoggingOutputStream(OutputStream output, Consumer<String> logger)
Initializes a logging output stream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Logs the output stream.void
write(int data)
-
Methods inherited from class java.io.OutputStream
flush, nullOutputStream, write, write
-
-
-
-
Constructor Detail
-
LoggingOutputStream
public LoggingOutputStream(OutputStream output, Consumer<String> logger)
Initializes a logging output stream.- Parameters:
output
- the output stream to loglogger
- the logger to use
-
-
Method Detail
-
write
public void write(int data) throws IOException
- Specified by:
write
in classOutputStream
- Throws:
IOException
-
close
public void close() throws IOException
Logs the output stream.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classOutputStream
- Throws:
IOException
-
-