Package jenkins.plugins.logstash
Class LogstashWriter
- java.lang.Object
-
- jenkins.plugins.logstash.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
-
-
Constructor Summary
Constructors Constructor Description LogstashWriter(Run<?,?> run, OutputStream error, TaskListener listener, Charset charset)
LogstashWriter(Run<?,?> run, OutputStream error, TaskListener listener, Charset charset, String stageName, String agentName)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description String
getCharset()
Gets the charset that Jenkins is using during this build.boolean
isConnectionBroken()
void
write(String line)
Sends a logstash payload for a single line to the indexer.void
writeBuildLog(int maxLines)
Sends a logstash payload containing log lines from the current build.
-
-
-
Constructor Detail
-
LogstashWriter
public LogstashWriter(Run<?,?> run, OutputStream error, TaskListener listener, Charset charset)
-
LogstashWriter
public LogstashWriter(Run<?,?> run, OutputStream error, TaskListener listener, Charset charset, String stageName, String agentName)
-
-
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.
-
-