Class AbstractPatternJsonProvider<Event extends DeferredProcessingAware>
java.lang.Object
ch.qos.logback.core.spi.ContextAwareBase
net.logstash.logback.composite.AbstractJsonProvider<Event>
net.logstash.logback.composite.AbstractPatternJsonProvider<Event>
- Type Parameters:
Event- type of event (ILoggingEventorIAccessEvent).
- All Implemented Interfaces:
ContextAware, JsonProvider<Event>, ObjectMapperAware
- Direct Known Subclasses:
AccessEventPatternJsonProvider, LoggingEventPatternJsonProvider
public abstract class AbstractPatternJsonProvider<Event extends DeferredProcessingAware>
extends AbstractJsonProvider<Event>
implements ObjectMapperAware
Transforms an string containing patterns understood by PatternLayouts into JSON output.
Delegates most of the work to the
AbstractJsonPatternParser that is to
parse the pattern specified.
Subclasses must implement createParser() method so it returns parser valid for a specified event class.- Author:
- Dmitry Andrianov
-
Field Summary
FieldsFields inherited from class ContextAwareBase
context -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected abstract AbstractJsonPatternParser<Event> booleanWhentrue, fields whose values are considered empty will be omitted from JSON output.voidsetObjectMapper(ObjectMapper objectMapper) voidsetOmitEmptyFields(boolean omitEmptyFields) Whentrue, fields whose values are considered empty will be omitted from JSON output.voidsetPattern(String pattern) voidstart()Start the provider after all configuration properties are set.voidwriteTo(JsonGenerator generator, Event event) Writes information about the event, to the given generator.Methods inherited from class AbstractJsonProvider
assertIsStarted, isStarted, prepareForDeferredProcessing, stopMethods inherited from class ContextAwareBase
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContextMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface ContextAware
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, setContext
-
Field Details
-
objectMapper
-
-
Constructor Details
-
AbstractPatternJsonProvider
public AbstractPatternJsonProvider()
-
-
Method Details
-
writeTo
Description copied from interface:JsonProviderWrites information about the event, to the given generator.When called, the generator is assumed to be within a JSON object context (i.e. this provider should write fields and their values to the generator). Upon return, the generator should be within the same JSON object context.
- Specified by:
writeToin interfaceJsonProvider<Event extends DeferredProcessingAware>- Parameters:
generator- theJsonGeneratorto produce JSON contentevent- the event to convert into JSON
-
createParser
-
getPattern
-
setPattern
-
setObjectMapper
- Specified by:
setObjectMapperin interfaceObjectMapperAware
-
start
public void start()Description copied from interface:JsonProviderStart the provider after all configuration properties are set.- Specified by:
startin interfaceJsonProvider<Event extends DeferredProcessingAware>- Overrides:
startin classAbstractJsonProvider<Event extends DeferredProcessingAware>
-
isOmitEmptyFields
public boolean isOmitEmptyFields()Whentrue, fields whose values are considered empty will be omitted from JSON output.- Returns:
trueif empty fields are omitted from JSON output,falseotherwise.
-
setOmitEmptyFields
public void setOmitEmptyFields(boolean omitEmptyFields) Whentrue, fields whose values are considered empty will be omitted from JSON output.- Parameters:
omitEmptyFields- whether empty fields are omitted or not
-