Class DeferredLogstashMarker

java.lang.Object
net.logstash.logback.marker.LogstashMarker
net.logstash.logback.marker.DeferredLogstashMarker
All Implemented Interfaces:
Serializable, Iterable<org.slf4j.Marker>, org.slf4j.Marker

public class DeferredLogstashMarker extends LogstashMarker
A LogstashMarker that defers the creation of another LogstashMarker until the first time it is encoded.

Encoding (and therefore the deferred marker creation) can potentially take place on another thread if an async appender (e.g. AsyncAppender or AsyncDisruptorAppender) is used.

The deferred value will only be calculated once. The single value supplied by the supplier will be reused every time the marker is written. For example, if multiple appenders use a logstash encoder, the supplier will be invoked when the first appender encodes the marker. That same supplied value will be used when the next appender encodes the marker.

See Also:
  • Field Details

  • Constructor Details

    • DeferredLogstashMarker

      public DeferredLogstashMarker(Supplier<? extends LogstashMarker> logstashMarkerSupplier)
  • Method Details

    • writeTo

      public void writeTo(JsonGenerator generator) throws IOException
      Description copied from class: LogstashMarker
      Writes the data associated with this marker to the given JsonGenerator.
      Specified by:
      writeTo in class LogstashMarker
      Parameters:
      generator - the generator to which to write the output of this marker.
      Throws:
      IOException - if there was an error writing to the generator
    • equals

      public boolean equals(Object obj)
      Specified by:
      equals in interface org.slf4j.Marker
    • hashCode

      public int hashCode()
      Specified by:
      hashCode in interface org.slf4j.Marker
    • getName

      public String getName()
      Specified by:
      getName in interface org.slf4j.Marker
    • hasReferences

      public boolean hasReferences()
      Specified by:
      hasReferences in interface org.slf4j.Marker
    • hasChildren

      @Deprecated public boolean hasChildren()
      Deprecated.
      Specified by:
      hasChildren in interface org.slf4j.Marker
    • iterator

      public Iterator<org.slf4j.Marker> iterator()
      Specified by:
      iterator in interface org.slf4j.Marker
    • remove

      public boolean remove(org.slf4j.Marker referenceToRemove)
      Specified by:
      remove in interface org.slf4j.Marker
    • contains

      public boolean contains(org.slf4j.Marker other)
      Specified by:
      contains in interface org.slf4j.Marker
    • contains

      public boolean contains(String name)
      Specified by:
      contains in interface org.slf4j.Marker