Class LogstashWriter

  • All Implemented Interfaces:
    Serializable

    public class LogstashWriter
    extends Object
    implements Serializable
    A writer that wraps all Logstash DAOs. Handles error reporting and per build connection state. Each call to write (one line or multiple lines) sends a Logstash payload to the DAO. If any write fails, writer will not attempt to send any further messages to logstash during this build.
    Since:
    1.0.5
    Author:
    Rusty Gerard, Liam Newman
    See Also:
    Serialized Form
    • Method Detail

      • getCharset

        public String getCharset()
        Gets the charset that Jenkins is using during this build.
        Returns:
        the charset
      • write

        public void write​(String line)
        Sends a logstash payload for a single line to the indexer. Call will be ignored if the line is empty or if the connection to the indexer is broken. If write fails, errors will logged to errorStream and connectionBroken will be set to true.
        Parameters:
        line - Message, not null
      • writeBuildLog

        public void writeBuildLog​(int maxLines)
        Sends a logstash payload containing log lines from the current build. Call will be ignored if the connection to the indexer is broken. If write fails, errors will logged to errorStream and connectionBroken will be set to true.
        Parameters:
        maxLines - Maximum number of lines to be written. Negative numbers mean "all lines".
      • isConnectionBroken

        public boolean isConnectionBroken()
        Returns:
        True if errors have occurred during initialization or write.