public class EventWriter
extends java.lang.Object
EventWriter
class encapsulates writing events and error messages to Splunk from a modular input.
Its two important methods are writeEvent
, which takes an Event
object, and log, which takes a severity
and an error message.Modifier and Type | Field and Description |
---|---|
static java.lang.String |
DEBUG |
static java.lang.String |
ERROR |
static java.lang.String |
FATAL |
static java.lang.String |
INFO |
static java.lang.String |
WARN |
Constructor and Description |
---|
EventWriter() |
EventWriter(java.io.Writer outputWriter,
java.io.Writer errorWriter) |
Modifier and Type | Method and Description |
---|---|
boolean |
checkError()
Returns whether there was an
IOException on this EventWriter. |
protected void |
clearError()
Clears the error state on this
EventWriter . |
void |
close()
Writes the closing
</stream> tag to make this XML well formed. |
void |
log(java.lang.String severity,
java.lang.String errorMessage)
Logs messages about the state of this modular input to Splunk.
|
protected void |
setError()
Declares that this
EventWriter had an IOException . |
void |
synchronizedLog(java.lang.String severity,
java.lang.String errorMessage)
Thread safe version of
log . |
void |
synchronizedWriteEvent(Event event)
Thread safe version of
writeEvent . |
void |
writeEvent(Event event)
Writes an
Event object to Splunk. |
public static java.lang.String DEBUG
public static java.lang.String INFO
public static java.lang.String WARN
public static java.lang.String ERROR
public static java.lang.String FATAL
public EventWriter() throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
public EventWriter(java.io.Writer outputWriter, java.io.Writer errorWriter) throws javax.xml.stream.XMLStreamException
javax.xml.stream.XMLStreamException
protected void clearError()
EventWriter
.
EventWriter
does not throw IOException
errors, but does not ignore them entirely either. Instead it operates
the same way as PrintStream
in the standard library. You can always check if an IOException
has been thrown
by calling checkError
.protected void setError()
EventWriter
had an IOException
.
EventWriter
does not throw IOException
errors, but does not ignore them entirely either. Instead it operates
the same way as PrintStream
in the standard library. You can always check if an IOException
has been thrown
by calling checkError
.public boolean checkError()
IOException
on this EventWriter.
EventWriter
does not throw IOException
errors, but does not ignore them entirely either. Instead it operates
the same way as PrintStream
in the standard library. You can always check if an IOException
has been thrown
by calling checkError
.public void synchronizedWriteEvent(Event event) throws MalformedDataException
writeEvent
.MalformedDataException
writeEvent(com.splunk.modularinput.Event)
public void writeEvent(Event event) throws MalformedDataException
Event
object to Splunk. This method is not thread safe. If you need a thread safe version, use
synchronizedWriteEvent
.
If you try to write an Event
with null data, throws MalformedDataException
.event
- The Event
object to write.MalformedDataException
synchronizedWriteEvent(com.splunk.modularinput.Event)
public void synchronizedLog(java.lang.String severity, java.lang.String errorMessage)
log
.log(java.lang.String, java.lang.String)
public void log(java.lang.String severity, java.lang.String errorMessage)
severity
- The severity (e.g., EventWriter.WARN
, EventWriter.FATAL
) of this message.errorMessage
- The message that should appear in the logs.synchronizedLog(java.lang.String, java.lang.String)
public void close()
</stream>
tag to make this XML well formed.