cz.cuni.amis.utils
Class StreamSink
java.lang.Object
java.lang.Thread
cz.cuni.amis.utils.StreamSink
- All Implemented Interfaces:
- Runnable
public class StreamSink
- extends Thread
Reads content of the stream and discards it.
Optionally it may log the content of the stream to some logger (i.e., redirects the output of the stream to some log).
Methods inherited from class java.lang.Thread |
activeCount, checkAccess, clone, countStackFrames, currentThread, destroy, dumpStack, enumerate, getAllStackTraces, getContextClassLoader, getDefaultUncaughtExceptionHandler, getId, getName, getPriority, getStackTrace, getState, getThreadGroup, getUncaughtExceptionHandler, holdsLock, interrupt, interrupted, isAlive, isDaemon, isInterrupted, join, join, join, resume, setContextClassLoader, setDaemon, setDefaultUncaughtExceptionHandler, setName, setPriority, setUncaughtExceptionHandler, sleep, sleep, start, stop, stop, suspend, toString, yield |
os
protected InputStream os
log
protected Logger log
logId
protected String logId
logLevel
protected Level logLevel
StreamSink
public StreamSink(String name,
InputStream os)
- Constructs the sink to silently discard all contents of 'os'.
- Parameters:
name
- name of the sink threados
- stream to be sunk
StreamSink
public StreamSink(String name,
InputStream os,
Logger log)
- Constructs the sink to redirect all output from 'os' into 'log' (used log level is
Level.INFO
) as default. May
be changed by setLogLevel(Level)
.
May
- Parameters:
name
- name of the sink threados
- log
-
StreamSink
public StreamSink(String name,
InputStream os,
Logger log,
String logId)
- Constructs the sink to redirect all output from 'os' into 'log' (used log level is
Level.INFO
) as default. May
be changed by setLogLevel(Level)
. Additionally all messages from the 'os' will be prefixed with 'logId+" "'.
- Parameters:
name
- name of the sink threados
- log
- logId
-
getLogLevel
public Level getLogLevel()
setLogLevel
public StreamSink setLogLevel(Level logLevel)
getLog
public Logger getLog()
setLog
protected StreamSink setLog(Logger log)
getLogId
public String getLogId()
setLogId
protected StreamSink setLogId(String logId)
handleInput
protected void handleInput(String str)
run
public void run()
- Specified by:
run
in interface Runnable
- Overrides:
run
in class Thread
Copyright © 2013 AMIS research group, Faculty of Mathematics and Physics, Charles University in Prague, Czech Republic. All Rights Reserved.