Package sonia.scm.logging
Class LoggingOutputStream
java.lang.Object
java.io.OutputStream
sonia.scm.logging.LoggingOutputStream
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
An OutputStream that flushes out to a Logger.
Based on LoggingOutputStream by Jim Moore
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final int
The default number of bytes in the buffer.static final int
static final int
static final int
static final int
static final int
-
Constructor Summary
ConstructorsConstructorDescriptionLoggingOutputStream
(org.slf4j.Logger logger, int level) Creates the LoggingOutputStream to flush to the given Logger. -
Method Summary
Modifier and TypeMethodDescriptionvoid
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.void
void
write
(int b) Writes the specified byte to this output stream.Methods inherited from class java.io.OutputStream
nullOutputStream, write, write
-
Field Details
-
DEFAULT_BUFFER_LENGTH
public static final int DEFAULT_BUFFER_LENGTHThe default number of bytes in the buffer.- See Also:
-
LEVEL_DEBUG
public static final int LEVEL_DEBUG- See Also:
-
LEVEL_ERROR
public static final int LEVEL_ERROR- See Also:
-
LEVEL_INFO
public static final int LEVEL_INFO- See Also:
-
LEVEL_TRACE
public static final int LEVEL_TRACE- See Also:
-
LEVEL_WARN
public static final int LEVEL_WARN- See Also:
-
-
Constructor Details
-
LoggingOutputStream
Creates the LoggingOutputStream to flush to the given Logger.- Parameters:
logger
- - the Logger to write tolevel
- - the Level to use when writing to the Logger- Throws:
IllegalArgumentException
- if cat == null or priority == null
-
-
Method Details
-
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
-
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
-
log
-
write
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
-