Class LoggingInputStream
- java.lang.Object
-
- java.io.InputStream
-
- dev.aherscu.qa.testing.utils.logging.LoggingInputStream
-
- All Implemented Interfaces:
Closeable
,AutoCloseable
public class LoggingInputStream extends InputStream
Logs the information passing through an input stream at trace level. The information will be logged uponclose()
.- Author:
- aherscu
- See Also:
Logger
-
-
Constructor Summary
Constructors Constructor Description LoggingInputStream(InputStream input, Consumer<String> logger)
Initializes a logging input stream.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Logs the input stream.int
read()
-
Methods inherited from class java.io.InputStream
available, mark, markSupported, nullInputStream, read, read, readAllBytes, readNBytes, readNBytes, reset, skip, transferTo
-
-
-
-
Constructor Detail
-
LoggingInputStream
public LoggingInputStream(InputStream input, Consumer<String> logger)
Initializes a logging input stream.- Parameters:
input
- the input stream to loglogger
- the logger to use
-
-
Method Detail
-
read
public int read() throws IOException
- Specified by:
read
in classInputStream
- Throws:
IOException
-
close
public void close() throws IOException
Logs the input stream.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classInputStream
- Throws:
IOException
-
-