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 |
contains(org.slf4j.Marker other) |
boolean |
contains(String name) |
boolean |
equals(Object obj) |
String |
getFieldName() |
protected abstract Object |
getFieldValue()
Return the value that should be included in the output of
LogstashMarker.toString() . |
String |
getName() |
boolean |
hasChildren()
Deprecated.
|
int |
hashCode() |
boolean |
hasReferences() |
Iterator<org.slf4j.Marker> |
iterator() |
boolean |
remove(org.slf4j.Marker referenceToRemove) |
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 . |
add, and, toString, with
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, wait
toString
forEach, iterator, spliterator
public static final String MARKER_NAME_PREFIX
public String getFieldName()
public void writeTo(JsonGenerator generator) throws IOException
LogstashMarker
JsonGenerator
.writeTo
in interface StructuredArgument
writeTo
in class LogstashMarker
generator
- 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
generator
- the generator to write JSONIOException
- if an I/O error occursprotected abstract void writeFieldValue(JsonGenerator generator) throws IOException
generator
- the generator to write JSONIOException
- if an I/O error occurspublic String toStringSelf()
LogstashMarker
Subclasses should override LogstashMarker.toStringSelf()
instead of LogstashMarker.toString()
,
since LogstashMarker.toString()
will automatically include the LogstashMarker.toStringSelf()
and references.
toStringSelf
in class LogstashMarker
protected abstract Object getFieldValue()
LogstashMarker.toString()
.public boolean equals(Object obj)
equals
in interface org.slf4j.Marker
public int hashCode()
hashCode
in interface org.slf4j.Marker
public String getName()
getName
in interface org.slf4j.Marker
public boolean hasReferences()
hasReferences
in interface org.slf4j.Marker
@Deprecated public boolean hasChildren()
hasChildren
in interface org.slf4j.Marker
public Iterator<org.slf4j.Marker> iterator()
iterator
in interface org.slf4j.Marker
public boolean remove(org.slf4j.Marker referenceToRemove)
remove
in interface org.slf4j.Marker
public boolean contains(org.slf4j.Marker other)
contains
in interface org.slf4j.Marker
public boolean contains(String name)
contains
in interface org.slf4j.Marker
Copyright © 2013–2022. All rights reserved.