public abstract class SingleFieldAppendingMarker extends LogstashMarker implements StructuredArgument
Marker OR StructuredArgument that appends
a single field into the JSON event.
When writing to the JSON data (via ArgumentsJsonProvider or LogstashMarkersJsonProvider):
writeFieldName(JsonGenerator),
which just uses fieldName is used as the field namewriteFieldValue(JsonGenerator),
which subclasses must override
When writing to a String (when used as a StructuredArgument to the event's formatted message),
the messageFormatPattern is used to construct the string output.
getFieldName() will be substituted in {0} in the messageFormatPattern.
getFieldValue() will be substituted in {1} in the messageFormatPattern.
Subclasses must override getFieldValue() to provide the field value to include.
| Modifier and Type | Field and Description |
|---|---|
static String |
MARKER_NAME_PREFIX |
| Constructor and Description |
|---|
SingleFieldAppendingMarker(String markerName,
String fieldName) |
SingleFieldAppendingMarker(String markerName,
String fieldName,
String messageFormatPattern) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
equals(Object obj) |
String |
getFieldName() |
abstract Object |
getFieldValue()
Return the value that should be included in the output of
LogstashMarker.toString(). |
int |
hashCode() |
String |
toStringSelf()
Returns a string representation of this object, without including any references.
|
protected void |
writeFieldName(JsonGenerator generator)
Writes the field name to the generator.
|
protected abstract void |
writeFieldValue(JsonGenerator generator)
Writes the field value to the generator.
|
void |
writeTo(JsonGenerator generator)
Writes the data associated with this marker to the given
JsonGenerator. |
and, toString, withadd, contains, contains, getName, hasChildren, hasReferences, iterator, removeclone, finalize, getClass, notify, notifyAll, toString, wait, wait, waittoStringforEach, iterator, spliteratorpublic static final String MARKER_NAME_PREFIX
public String getFieldName()
public void writeTo(JsonGenerator generator) throws IOException
LogstashMarkerJsonGenerator.writeTo in interface StructuredArgumentwriteTo in class LogstashMarkergenerator - the generator to which to write the output of this marker.IOException - if there was an error writing to the generatorprotected void writeFieldName(JsonGenerator generator) throws IOException
IOExceptionprotected abstract void writeFieldValue(JsonGenerator generator) throws IOException
IOExceptionpublic String toStringSelf()
LogstashMarkerSubclasses should override LogstashMarker.toStringSelf() instead of LogstashMarker.toString(),
since LogstashMarker.toString() will automatically include the LogstashMarker.toStringSelf() and references.
toStringSelf in class LogstashMarkerpublic abstract Object getFieldValue()
LogstashMarker.toString().public boolean equals(Object obj)
equals in interface org.slf4j.Markerequals in class LogstashBasicMarkerpublic int hashCode()
hashCode in interface org.slf4j.MarkerhashCode in class LogstashBasicMarkerCopyright © 2020. All rights reserved.