Package org.apache.commons.exec
Class LogOutputStream
java.lang.Object
java.io.OutputStream
org.apache.commons.exec.LogOutputStream
- All Implemented Interfaces:
- Closeable,- Flushable,- AutoCloseable
Base class to connect a logging system to the output and/or error stream of then external process. The implementation parses the incoming data to construct a
 line and passes the complete line to an user-defined implementation.
- 
Constructor SummaryConstructorsConstructorDescriptionCreates a new instance of this class.LogOutputStream(int level) Creates a new instance of this class.LogOutputStream(int level, Charset charset) Creates a new instance of this class, specifying the character set that should be used for outputting the string for each line
- 
Method SummaryModifier and TypeMethodDescriptionvoidclose()Writes all remaining data from the buffer.voidflush()Flushes this log stream.intGets the trace level of the log system.protected voidConverts the buffer to a string and sends it toprocessLine.protected voidprocessLine(String line) Logs a line to the log system of the user.protected abstract voidprocessLine(String line, int logLevel) Logs a line to the log system of the user.voidwrite(byte[] b, int off, int len) Writes a block of characters to the output stream.voidwrite(int cc) Writes the data to the buffer and flush the buffer, if a line separator is detected.Methods inherited from class java.io.OutputStreamwrite
- 
Constructor Details- 
LogOutputStreampublic LogOutputStream()Creates a new instance of this class. Uses the default level of 999.
- 
LogOutputStreamCreates a new instance of this class.- Parameters:
- level- level used to log data written to this stream.
 
- 
LogOutputStreamCreates a new instance of this class, specifying the character set that should be used for outputting the string for each line- Parameters:
- level- level used to log data written to this stream.
- charset- Character Set to use when processing lines.
 
 
- 
- 
Method Details- 
closeWrites all remaining data from the buffer.- Specified by:
- closein interface- AutoCloseable
- Specified by:
- closein interface- Closeable
- Overrides:
- closein class- OutputStream
- Throws:
- IOException
- See Also:
 
- 
flushFlushes this log stream.- Specified by:
- flushin interface- Flushable
- Overrides:
- flushin class- OutputStream
- See Also:
 
- 
getMessageLevelGets the trace level of the log system.- Returns:
- the trace level of the log system.
 
- 
processBufferConverts the buffer to a string and sends it toprocessLine.
- 
processLineLogs a line to the log system of the user.- Parameters:
- line- the line to log.
 
- 
processLineLogs a line to the log system of the user.- Parameters:
- line- the line to log.
- logLevel- the log level to use
 
- 
writeWrites a block of characters to the output stream.- Overrides:
- writein class- OutputStream
- Parameters:
- b- the array containing the data.
- off- the offset into the array where data starts.
- len- the length of block.
- Throws:
- IOException- if the data cannot be written into the stream.
- See Also:
 
- 
writeWrites the data to the buffer and flush the buffer, if a line separator is detected.- Specified by:
- writein class- OutputStream
- Parameters:
- cc- data to log (byte).
- Throws:
- IOException
- See Also:
 
 
-