Package hudson.util
Class StreamTaskListener
- java.lang.Object
-
- hudson.util.AbstractTaskListener
-
- hudson.util.StreamTaskListener
-
- All Implemented Interfaces:
TaskListener,Closeable,Serializable,AutoCloseable,org.jenkinsci.remoting.SerializableOnlyOverRemoting
- Direct Known Subclasses:
StreamBuildListener
public class StreamTaskListener extends AbstractTaskListener implements TaskListener, Closeable
TaskListenerthat generates output into a single stream.This object is remotable.
- Author:
- Kohsuke Kawaguchi
- See Also:
- Serialized Form
-
-
Field Summary
-
Fields inherited from interface hudson.model.TaskListener
NULL
-
-
Constructor Summary
Constructors Constructor Description StreamTaskListener()Deprecated.as of 1.349 UseTaskListener.NULLStreamTaskListener(File out)Deprecated.as of TODO The caller should useStreamTaskListener(File, Charset)to pass in the charset and file separately, so that this class can handle encoding correctly.StreamTaskListener(File out, boolean append, Charset charset)Constructs aStreamTaskListenerthat sends the output to a specified file.StreamTaskListener(File out, Charset charset)StreamTaskListener(OutputStream out)Deprecated.as of TODO The caller should useStreamTaskListener(OutputStream, Charset)to pass in the charset and output stream separately, so that this class can handle encoding correctly, or usefromStdout()orfromStderr().StreamTaskListener(OutputStream out, Charset charset)StreamTaskListener(PrintStream out)Deprecated.as of 1.349 The caller should useStreamTaskListener(OutputStream, Charset)to pass in the charset and output stream separately, so that this class can handle encoding correctly, or usefromStdout()orfromStderr().StreamTaskListener(Writer w)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidclose()voidcloseQuietly()Closes this listener and swallows any exceptions, if raised.static StreamTaskListenerfromStderr()static StreamTaskListenerfromStdout()CharsetgetCharset()A charset to use for methods returningPrintWriter.PrintStreamgetLogger()This writer will receive the output of the build-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.jenkinsci.remoting.SerializableOnlyOverRemoting
getChannelForSerialization
-
Methods inherited from interface hudson.model.TaskListener
annotate, error, error, fatalError, fatalError, hyperlink
-
-
-
-
Constructor Detail
-
StreamTaskListener
@Deprecated public StreamTaskListener(@NonNull PrintStream out)
Deprecated.as of 1.349 The caller should useStreamTaskListener(OutputStream, Charset)to pass in the charset and output stream separately, so that this class can handle encoding correctly, or usefromStdout()orfromStderr().
-
StreamTaskListener
@Deprecated public StreamTaskListener(@NonNull OutputStream out)
Deprecated.as of TODO The caller should useStreamTaskListener(OutputStream, Charset)to pass in the charset and output stream separately, so that this class can handle encoding correctly, or usefromStdout()orfromStderr().
-
StreamTaskListener
public StreamTaskListener(@NonNull OutputStream out, @CheckForNull Charset charset)
-
StreamTaskListener
@Deprecated public StreamTaskListener(@NonNull File out) throws IOException
Deprecated.as of TODO The caller should useStreamTaskListener(File, Charset)to pass in the charset and file separately, so that this class can handle encoding correctly.- Throws:
IOException
-
StreamTaskListener
public StreamTaskListener(@NonNull File out, @CheckForNull Charset charset) throws IOException- Throws:
IOException
-
StreamTaskListener
public StreamTaskListener(@NonNull File out, boolean append, @CheckForNull Charset charset) throws IOExceptionConstructs aStreamTaskListenerthat sends the output to a specified file.- Parameters:
out- the file.append- iftrue, then output will be written to the end of the file rather than the beginning.charset- if non-nullthen the charset to use when writing.- Throws:
IOException- if the file could not be opened.- Since:
- 1.651
-
StreamTaskListener
public StreamTaskListener(@NonNull Writer w) throws IOException- Throws:
IOException
-
StreamTaskListener
@Deprecated public StreamTaskListener() throws IOException
Deprecated.as of 1.349 UseTaskListener.NULL- Throws:
IOException
-
-
Method Detail
-
fromStdout
public static StreamTaskListener fromStdout()
-
fromStderr
public static StreamTaskListener fromStderr()
-
getLogger
public PrintStream getLogger()
Description copied from interface:TaskListenerThis writer will receive the output of the build- Specified by:
getLoggerin interfaceTaskListener
-
getCharset
public Charset getCharset()
Description copied from interface:TaskListenerA charset to use for methods returningPrintWriter. Should match that used to constructTaskListener.getLogger().- Specified by:
getCharsetin interfaceTaskListener- Returns:
- by default, UTF-8
-
close
public void close() throws IOException- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceCloseable- Throws:
IOException
-
closeQuietly
public void closeQuietly()
Closes this listener and swallows any exceptions, if raised.- Since:
- 1.349
-
-