Package ucar.unidata.util.test
Class SysStreamLogger.LoggingOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- ucar.unidata.util.test.SysStreamLogger.LoggingOutputStream
-
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
- Enclosing class:
- SysStreamLogger
protected static class SysStreamLogger.LoggingOutputStream extends OutputStream
-
-
Field Summary
Fields Modifier and Type Field Description protected byte[]
buf
The internal buffer where data is stored.protected int
bufLength
Remembers the size of the buffer for speed.protected int
count
The number of valid bytes in the buffer.static int
DEFAULT_BUFFER_LENGTH
The default number of bytes in the buffer.protected boolean
hasBeenClosed
Used to maintain the contract ofclose()
.protected boolean
isError
protected org.slf4j.Logger
log
-
Constructor Summary
Constructors Modifier Constructor Description protected
LoggingOutputStream()
LoggingOutputStream(org.slf4j.Logger log, boolean isError)
Creates the LoggingOutputStream to flush to the given Category.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Closes this output stream and releases any system resources associated with this stream.void
flush()
Flushes this output stream and forces any buffered output bytes to be written out.protected void
reset()
void
write(int b)
Writes the specified byte to this output stream.-
Methods inherited from class java.io.OutputStream
nullOutputStream, write, write
-
-
-
-
Field Detail
-
log
protected org.slf4j.Logger log
-
isError
protected boolean isError
-
hasBeenClosed
protected boolean hasBeenClosed
Used to maintain the contract ofclose()
.
-
buf
protected byte[] buf
The internal buffer where data is stored.
-
count
protected int count
The number of valid bytes in the buffer. This value is always in the range 0 through buf.length; elements buf[0] through buf[count-1] contain valid byte data.
-
bufLength
protected int bufLength
Remembers the size of the buffer for speed.
-
DEFAULT_BUFFER_LENGTH
public static final int DEFAULT_BUFFER_LENGTH
The default number of bytes in the buffer. =2048- See Also:
- Constant Field Values
-
-
Constructor Detail
-
LoggingOutputStream
protected LoggingOutputStream()
-
LoggingOutputStream
public LoggingOutputStream(org.slf4j.Logger log, boolean isError) throws IllegalArgumentException
Creates the LoggingOutputStream to flush to the given Category.- Parameters:
log
- the Logger to write toisError
- the if true write to error, else info- Throws:
IllegalArgumentException
- if cat == null or priority == null
-
-
Method Detail
-
close
public void close()
Closes this output stream and releases any system resources associated with this stream. The general contract ofclose
is that it closes the output stream. A closed stream cannot perform output operations and cannot be reopened.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Overrides:
close
in classOutputStream
-
write
public void write(int b) throws IOException
Writes the specified byte to this output stream. The general contract forwrite
is that one byte is written to the output stream. The byte to be written is the eight low-order bits of the argumentb
. The 24 high-order bits ofb
are ignored.- Specified by:
write
in classOutputStream
- Parameters:
b
- thebyte
to write- Throws:
IOException
-
flush
public void flush()
Flushes this output stream and forces any buffered output bytes to be written out. The general contract offlush
is that calling it is an indication that, if any bytes previously written have been buffered by the implementation of the output stream, such bytes should immediately be written to their intended destination.- Specified by:
flush
in interfaceFlushable
- Overrides:
flush
in classOutputStream
-
reset
protected void reset()
-
-