Package net.logstash.logback.marker
Class SingleFieldAppendingMarker
java.lang.Object
net.logstash.logback.marker.LogstashMarker
net.logstash.logback.marker.SingleFieldAppendingMarker
- All Implemented Interfaces:
Serializable
,Iterable<org.slf4j.Marker>
,StructuredArgument
,org.slf4j.Marker
- Direct Known Subclasses:
ObjectAppendingMarker
,RawJsonAppendingMarker
public abstract class SingleFieldAppendingMarker
extends LogstashMarker
implements StructuredArgument
A
Marker
OR StructuredArgument
that appends
a single field into the JSON event.
When writing to the JSON data (via ArgumentsJsonProvider
or LogstashMarkersJsonProvider
):
- Field names are written via
writeFieldName(JsonGenerator)
, which just usesfieldName
is used as the field name - Values are written via
writeFieldValue(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.
- See Also:
-
Field Summary
Fields inherited from interface org.slf4j.Marker
ANY_MARKER, ANY_NON_NULL_MARKER
-
Constructor Summary
ConstructorDescriptionSingleFieldAppendingMarker
(String markerName, String fieldName) SingleFieldAppendingMarker
(String markerName, String fieldName, String messageFormatPattern) -
Method Summary
Modifier and TypeMethodDescriptionboolean
boolean
contains
(org.slf4j.Marker other) boolean
protected abstract Object
Return the value that should be included in the output ofLogstashMarker.toString()
.getName()
boolean
Deprecated.int
hashCode()
boolean
Iterator<org.slf4j.Marker>
iterator()
boolean
remove
(org.slf4j.Marker referenceToRemove) 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 givenJsonGenerator
.Methods inherited from class net.logstash.logback.marker.LogstashMarker
add, and, toString, with
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
Methods inherited from interface java.lang.Iterable
forEach, iterator, spliterator
Methods inherited from interface net.logstash.logback.argument.StructuredArgument
toString
-
Field Details
-
MARKER_NAME_PREFIX
- See Also:
-
-
Constructor Details
-
SingleFieldAppendingMarker
-
SingleFieldAppendingMarker
-
-
Method Details
-
getFieldName
-
writeTo
Description copied from class:LogstashMarker
Writes the data associated with this marker to the givenJsonGenerator
.- Specified by:
writeTo
in interfaceStructuredArgument
- Specified by:
writeTo
in classLogstashMarker
- Parameters:
generator
- the generator to which to write the output of this marker.- Throws:
IOException
- if there was an error writing to the generator
-
writeFieldName
Writes the field name to the generator.- Parameters:
generator
- the generator to write JSON- Throws:
IOException
- if an I/O error occurs
-
writeFieldValue
Writes the field value to the generator.- Parameters:
generator
- the generator to write JSON- Throws:
IOException
- if an I/O error occurs
-
toStringSelf
Description copied from class:LogstashMarker
Returns a string representation of this object, without including any references.Subclasses should override
LogstashMarker.toStringSelf()
instead ofLogstashMarker.toString()
, sinceLogstashMarker.toString()
will automatically include theLogstashMarker.toStringSelf()
and references.- Overrides:
toStringSelf
in classLogstashMarker
- Returns:
- a string representation of this object, without including any references.
-
getFieldValue
Return the value that should be included in the output ofLogstashMarker.toString()
.- Returns:
- the field value
-
equals
- Specified by:
equals
in interfaceorg.slf4j.Marker
-
hashCode
public int hashCode()- Specified by:
hashCode
in interfaceorg.slf4j.Marker
-
getName
- Specified by:
getName
in interfaceorg.slf4j.Marker
-
hasReferences
public boolean hasReferences()- Specified by:
hasReferences
in interfaceorg.slf4j.Marker
-
hasChildren
Deprecated.- Specified by:
hasChildren
in interfaceorg.slf4j.Marker
-
iterator
- Specified by:
iterator
in interfaceorg.slf4j.Marker
-
remove
public boolean remove(org.slf4j.Marker referenceToRemove) - Specified by:
remove
in interfaceorg.slf4j.Marker
-
contains
public boolean contains(org.slf4j.Marker other) - Specified by:
contains
in interfaceorg.slf4j.Marker
-
contains
- Specified by:
contains
in interfaceorg.slf4j.Marker
-