Package com.iizix
Class LogStreamRedirector
java.lang.Object
com.iizix.LogStreamRedirector
Input stream redirector class to the IIZI log. It is typically used to redirect the output of an external process to the log.
- Author:
- Christopher Mindus
- Constructor SummaryConstructorsConstructorDescription- LogStreamRedirector- (int level, String originator, InputStream inputStream) Creates a stream reader redirector to the IIZI log, running in a separate thread.- LogStreamRedirector- (int level, String originator, String prefix, InputStream inputStream) Creates a stream reader redirector to the IIZI log, running in a separate thread.
- Method SummaryModifier and TypeMethodDescription- void- close()Closes the stream reader redirector without completing potential pending unprocessed input in the stream.- booleanWaits indefinitely for the stream reader to complete all input reading by waiting for the input stream to be closed, then disposes of this instance.- boolean- closeWait- (long timeout) Waits for the stream reader to complete all input reading by waiting for the input stream to be closed, then disposes of this instance.- static void- createStreamReadirector- (int level, String originator, Process process) Helper to create a stdout stream reader redirecting to the log when the process stderr has been redirected to stdout.- static void- createStreamReadirectors- (String originator, Process process) Helper to create stdout and stderr stream readers redirecting to the log.- boolean- isClosed()Checks whether this stream reader instance is disposed of or not.- static boolean- shouldIgnore- (int level, String msg) Checks if a log message should be ignored or not, typically SEVERE level messages for different ANTLR versions used at runtime or parser, thus omitting "worrying" SEVERE ANTLR version mismatch when "not dangerous".
- Constructor Details- LogStreamRedirectorCreates a stream reader redirector to the IIZI log, running in a separate thread.- Parameters:
- level- Log level (1-7), e.g.- ILog.INFOor- ILog.SEVERE.
- originator- The originator.
- inputStream- The input stream.
 
- LogStreamRedirectorCreates a stream reader redirector to the IIZI log, running in a separate thread.- Parameters:
- level- Log level (1-7), e.g.- ILog.INFOor- ILog.SEVERE.
- originator- The originator.
- prefix- Prefix for each line,- nullor empty string for none.
- inputStream- The input stream.
 
 
- Method Details- shouldIgnoreChecks if a log message should be ignored or not, typically SEVERE level messages for different ANTLR versions used at runtime or parser, thus omitting "worrying" SEVERE ANTLR version mismatch when "not dangerous".- Parameters:
- level- The log level.
- msg- The message.
- Returns:
- trueif the- msgis a message like- ANTLR Tool version 4.10.1 used for code generation does not match the current runtime version 4.11.1or- ANTLR Runtime version 4.10.1 used for parser compilation does not match the current runtime version 4.11.1.
 
- createStreamReadirectorHelper to create a stdout stream reader redirecting to the log when the process stderr has been redirected to stdout.- Parameters:
- level- The log level.
- originator- The originator.
- process- The process.
 
- createStreamReadirectorsHelper to create stdout and stderr stream readers redirecting to the log.- Parameters:
- originator- The originator.
- process- The process.
 
- closeWaitWaits indefinitely for the stream reader to complete all input reading by waiting for the input stream to be closed, then disposes of this instance.- Returns:
- Success flag.
- Throws:
- InterruptedException- In case the waiting was interrupted.
 
- closeWaitWaits for the stream reader to complete all input reading by waiting for the input stream to be closed, then disposes of this instance.- Parameters:
- timeout- The timeout to wait for the thread,- -1Lfor indefinite wait.
- Returns:
- Success flag.
- Throws:
- InterruptedException- In case the waiting was interrupted.
 
- isClosedpublic boolean isClosed()Checks whether this stream reader instance is disposed of or not.- Returns:
- The dispose state.
 
- closepublic void close()Closes the stream reader redirector without completing potential pending unprocessed input in the stream.