Package net.logstash.logback.argument
Class DeferredStructuredArgument
java.lang.Object
net.logstash.logback.argument.DeferredStructuredArgument
- All Implemented Interfaces:
StructuredArgument
A
StructuredArgument
that defers the creation of another StructuredArgument
until
the first time its value is needed.
The value is needed in the following conditions:
- When
LoggingEvent.getFormattedMessage()
is called - When
LoggingEvent.prepareForDeferredProcessing()
()} is called (async appenders call this prior to dispatching the event to another thread) - When the
LoggingEvent
is encoded
The deferred value will always be created in the thread calling the Logger
(even if an async appender is used) since the values of structured arguments are needed
when LoggingEvent.prepareForDeferredProcessing()
is called
(by async appenders prior to dispatching the event to another thread).
The deferred value will only be calculated once. The single value supplied by the supplier will be reused every time the structured argument 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.
-
Constructor Summary
ConstructorsConstructorDescriptionDeferredStructuredArgument
(Supplier<? extends StructuredArgument> structureArgumentSupplier) -
Method Summary
Modifier and TypeMethodDescriptionvoid
writeTo
(JsonGenerator generator) Writes the data associated with this argument to the givenJsonGenerator
.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface net.logstash.logback.argument.StructuredArgument
toString
-
Constructor Details
-
DeferredStructuredArgument
-
-
Method Details
-
writeTo
Description copied from interface:StructuredArgument
Writes the data associated with this argument to the givenJsonGenerator
.- Specified by:
writeTo
in interfaceStructuredArgument
- Parameters:
generator
- theJsonGenerator
to produce JSON content- Throws:
IOException
- if an I/O error occurs
-