Class TimestampingOutputStream
- java.lang.Object
-
- java.io.OutputStream
-
- hudson.console.LineTransformationOutputStream
-
- com.sumologic.jenkins.jenkinssumologicplugin.sender.TimestampingOutputStream
-
- All Implemented Interfaces:
Closeable
,Flushable
,AutoCloseable
public class TimestampingOutputStream extends LineTransformationOutputStream
OutputStream decorator that for each new line in the stream additionally adds a consistent timestamp and forwards the rest of the stream line without modifications.Created by lukasz on 3/21/17.
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class hudson.console.LineTransformationOutputStream
LineTransformationOutputStream.Delegating
-
-
Constructor Summary
Constructors Constructor Description TimestampingOutputStream(OutputStream stream)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
eol(byte[] bytes, int i)
static byte[]
getTimestampAsByteArray()
static byte[]
getTimestampAsByteArray(String jobName, String jobNumber)
static boolean
shouldPutTimestamp(byte[] bytes, int i)
Heuristic used for determining multiline log messages, e.g.-
Methods inherited from class hudson.console.LineTransformationOutputStream
close, forceEol, trimEOL, write, write
-
Methods inherited from class java.io.OutputStream
flush, nullOutputStream, write
-
-
-
-
Constructor Detail
-
TimestampingOutputStream
public TimestampingOutputStream(OutputStream stream)
-
-
Method Detail
-
shouldPutTimestamp
public static boolean shouldPutTimestamp(byte[] bytes, int i)
Heuristic used for determining multiline log messages, e.g. stack traces. For Sumo Logic purposes only lines prefixed with timestamp will be considered a beginning of new log message.- Parameters:
bytes
- - byte array containing single log linei
- - log line length (can be less that bytes.length)- Returns:
- false if line starts with whitespace, true otherwise
-
getTimestampAsByteArray
public static byte[] getTimestampAsByteArray(String jobName, String jobNumber)
-
getTimestampAsByteArray
public static byte[] getTimestampAsByteArray()
-
eol
protected void eol(byte[] bytes, int i) throws IOException
- Specified by:
eol
in classLineTransformationOutputStream
- Throws:
IOException
-
-