Class 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.

    • 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 line
        i - - 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()