public class EventWriter extends 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 String |
DEBUG |
static String |
ERROR |
static String |
FATAL |
static String |
INFO |
static String |
WARN |
Constructor and Description |
---|
EventWriter() |
EventWriter(Writer outputWriter,
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(String severity,
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(String severity,
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 String DEBUG
public static String INFO
public static String WARN
public static String ERROR
public static String FATAL
public EventWriter() throws XMLStreamException
XMLStreamException
public EventWriter(Writer outputWriter, Writer errorWriter) throws XMLStreamException
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
.event
- The Event instanceMalformedDataException
- The MalformedDataException instancewriteEvent(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
- The MalformedDataException instancesynchronizedWriteEvent(com.splunk.modularinput.Event)
public void synchronizedLog(String severity, String errorMessage)
log
.severity
- String valueerrorMessage
- String valuelog(java.lang.String, java.lang.String)
public void log(String severity, 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.Copyright © 2022 Splunk, Inc.. All rights reserved.