Class AbstractLogCommandOutput
- java.lang.Object
-
- com.anrisoftware.globalpom.exec.internal.logoutputs.AbstractLogCommandOutput
-
- All Implemented Interfaces:
CommandOutput,LogCommandOutput,Callable<CommandOutput>
- Direct Known Subclasses:
AbstractLogCommandOutput.DebugLogCommandOutput,AbstractLogCommandOutput.ErrorLogCommandOutput,AbstractLogCommandOutput.InfoLogCommandOutput,AbstractLogCommandOutput.TraceLogCommandOutput
public abstract class AbstractLogCommandOutput extends Object implements LogCommandOutput
Pipes the read data from the output of the command to a logger.- Since:
- 2.0
- Author:
- Erwin Mueller, erwin.mueller@deventm.org
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAbstractLogCommandOutput.DebugLogCommandOutputLogs the output as debug level.static classAbstractLogCommandOutput.ErrorLogCommandOutputLogs the output as error level.static classAbstractLogCommandOutput.InfoLogCommandOutputLogs the output as info level.static classAbstractLogCommandOutput.TraceLogCommandOutputLogs the output as trace level.
-
Constructor Summary
Constructors Modifier Constructor Description protectedAbstractLogCommandOutput(org.slf4j.Logger logger, CommandLine commandLine)
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description CommandOutputcall()Reads the standard output from the connected stream.abstract CommandOutputclone()Clones the standard output reader.static CommandOutputcreateDebugLogCommandOutput(org.slf4j.Logger logger, CommandLine commandLine)static CommandOutputcreateErrorLogCommandOutput(org.slf4j.Logger logger, CommandLine commandLine)static CommandOutputcreateInfoLogCommandOutput(org.slf4j.Logger logger, CommandLine commandLine)static CommandOutputcreateTraceLogCommandOutput(org.slf4j.Logger logger, CommandLine commandLine)StringgetCommand()Returns the command for the logging message.CommandLinegetCommandLine()Returns the command line for the logging message.InputStreamgetInput()Returns the stream that is connected to output of the executed command.org.slf4j.LoggergetLogger()Returns the logger that is filled with the piped to the output of the command.StringgetMessage()Returns the message string.protected abstract voidlogLine(String line)Log the line red from the command output.voidsetBufferSize(int size)Sets the buffer size.voidsetInput(InputStream stream)Sets the stream that is connected to output of the executed command.voidsetLogger(org.slf4j.Logger logger)Sets the logger that is filled with the piped to the output of the command.voidsetMessage(String message)Sets the message string.StringtoString()
-
-
-
Constructor Detail
-
AbstractLogCommandOutput
protected AbstractLogCommandOutput(org.slf4j.Logger logger, CommandLine commandLine)- Parameters:
logger- theLogger.commandLine- the theCommandLinefor the logging message.
-
-
Method Detail
-
createInfoLogCommandOutput
public static CommandOutput createInfoLogCommandOutput(org.slf4j.Logger logger, CommandLine commandLine)
- Parameters:
logger- theLoggercommandLine- theCommandLine- Returns:
- the
CommandOutput
-
createDebugLogCommandOutput
public static CommandOutput createDebugLogCommandOutput(org.slf4j.Logger logger, CommandLine commandLine)
- Parameters:
logger- theLoggercommandLine- theCommandLine- Returns:
- the
CommandOutput
-
createTraceLogCommandOutput
public static CommandOutput createTraceLogCommandOutput(org.slf4j.Logger logger, CommandLine commandLine)
- Parameters:
logger- theLoggercommandLine- theCommandLine- Returns:
- the
CommandOutput
-
createErrorLogCommandOutput
public static CommandOutput createErrorLogCommandOutput(org.slf4j.Logger logger, CommandLine commandLine)
- Parameters:
logger- theLoggercommandLine- theCommandLine- Returns:
- the
CommandOutput
-
setInput
public void setInput(InputStream stream)
Description copied from interface:CommandOutputSets the stream that is connected to output of the executed command.- Specified by:
setInputin interfaceCommandOutput- Parameters:
stream- theInputStream.
-
getInput
public InputStream getInput()
Description copied from interface:LogCommandOutputReturns the stream that is connected to output of the executed command.- Specified by:
getInputin interfaceLogCommandOutput- Returns:
- the
InputStream.
-
setBufferSize
public void setBufferSize(int size)
Description copied from interface:LogCommandOutputSets the buffer size.- Specified by:
setBufferSizein interfaceLogCommandOutput- Parameters:
size- the size in bytes.
-
setLogger
public void setLogger(org.slf4j.Logger logger)
Description copied from interface:LogCommandOutputSets the logger that is filled with the piped to the output of the command.- Specified by:
setLoggerin interfaceLogCommandOutput- Parameters:
logger- theLogger.
-
getLogger
public org.slf4j.Logger getLogger()
Description copied from interface:LogCommandOutputReturns the logger that is filled with the piped to the output of the command.- Specified by:
getLoggerin interfaceLogCommandOutput- Returns:
- the
Logger.
-
getCommandLine
public CommandLine getCommandLine()
Description copied from interface:LogCommandOutputReturns the command line for the logging message.- Specified by:
getCommandLinein interfaceLogCommandOutput- Returns:
- the
CommandLine.
-
getCommand
public String getCommand()
Description copied from interface:LogCommandOutputReturns the command for the logging message.- Specified by:
getCommandin interfaceLogCommandOutput- Returns:
- the
Stringcommand.
-
setMessage
public void setMessage(String message)
Description copied from interface:LogCommandOutputSets the message string.- Specified by:
setMessagein interfaceLogCommandOutput- Parameters:
message- theStringmessage.
-
getMessage
public String getMessage()
Description copied from interface:LogCommandOutputReturns the message string.- Specified by:
getMessagein interfaceLogCommandOutput- Returns:
- the
Stringmessage.
-
call
public CommandOutput call() throws Exception
Description copied from interface:CommandOutputReads the standard output from the connected stream.- Specified by:
callin interfaceCallable<CommandOutput>- Specified by:
callin interfaceCommandOutput- Throws:
Exception
-
clone
public abstract CommandOutput clone()
Description copied from interface:CommandOutputClones the standard output reader. The cloned reader have the same connected input stream.- Specified by:
clonein interfaceCommandOutput- Overrides:
clonein classObject- Returns:
- the cloned
CommandOutput.
-
logLine
protected abstract void logLine(String line)
Log the line red from the command output.- Parameters:
line- theStringline.
-
-