Package com.github.loki4j.logback.json
Class AbstractFieldCollectionJsonProvider<V,E,T extends java.util.Collection<E>>
- java.lang.Object
-
- ch.qos.logback.core.spi.ContextAwareBase
-
- com.github.loki4j.logback.json.AbstractJsonProvider
-
- com.github.loki4j.logback.json.AbstractFieldCollectionJsonProvider<V,E,T>
-
- Type Parameters:
V- Type of the field value supported by this provider.E- Type of key-value entry served by this provider.T- Type of key-value collection served by this provider.
- All Implemented Interfaces:
ch.qos.logback.core.spi.ContextAware,ch.qos.logback.core.spi.LifeCycle,JsonProvider<ch.qos.logback.classic.spi.ILoggingEvent>
- Direct Known Subclasses:
KeyValuePairsJsonProvider,MdcJsonProvider
public abstract class AbstractFieldCollectionJsonProvider<V,E,T extends java.util.Collection<E>> extends AbstractJsonProvider
An abstract provider that writes a collection of JSON fields
-
-
Constructor Summary
Constructors Constructor Description AbstractFieldCollectionJsonProvider()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description voidaddExclude(java.lang.String key)voidaddInclude(java.lang.String key)booleancanWrite(ch.qos.logback.classic.spi.ILoggingEvent event)Indicates if this provider can write anything for a particular event.protected abstract TextractEntries(ch.qos.logback.classic.spi.ILoggingEvent event)Extract the collection of entries (i.e.protected abstract java.lang.StringextractKey(E entry)Extract the key (i.e.protected abstract VextractValue(E entry)Extract the value (i.e.java.lang.StringgetPrefix()booleanisNoPrefix()voidsetNoPrefix(boolean noPrefix)voidsetPrefix(java.lang.String prefix)protected abstract voidwriteField(JsonEventWriter writer, java.lang.String fieldName, V fieldValue)Write a field into JSON event layout.booleanwriteTo(JsonEventWriter writer, ch.qos.logback.classic.spi.ILoggingEvent event, boolean startWithSeparator)Writes a certain aspect of event into a writer.-
Methods inherited from class com.github.loki4j.logback.json.AbstractJsonProvider
isEnabled, isStarted, setEnabled, start, stop
-
Methods inherited from class ch.qos.logback.core.spi.ContextAwareBase
addError, addError, addInfo, addInfo, addStatus, addWarn, addWarn, getContext, getDeclaredOrigin, getStatusManager, setContext
-
-
-
-
Method Detail
-
canWrite
public boolean canWrite(ch.qos.logback.classic.spi.ILoggingEvent event)
Description copied from interface:JsonProviderIndicates if this provider can write anything for a particular event. If this method returnsfalse,writeTo()should not be called for a particular event. You can put all your preliminary checks here, no need to duplicated them inwriteTo().
-
writeTo
public boolean writeTo(JsonEventWriter writer, ch.qos.logback.classic.spi.ILoggingEvent event, boolean startWithSeparator)
Description copied from interface:JsonProviderWrites a certain aspect of event into a writer.- Parameters:
writer- JSON writer to use.event- Current logback event.startWithSeparator- Iftrue, a separator should be written before writing anything else.- Returns:
- If anything was effectively written during this call.
-
extractEntries
protected abstract T extractEntries(ch.qos.logback.classic.spi.ILoggingEvent event)
Extract the collection of entries (i.e. fields) from the logging event.- Parameters:
event- Current logback event.
-
extractKey
protected abstract java.lang.String extractKey(E entry)
Extract the key (i.e. field name) from the collection entry.
-
extractValue
protected abstract V extractValue(E entry)
Extract the value (i.e. field value) from the collection entry.
-
writeField
protected abstract void writeField(JsonEventWriter writer, java.lang.String fieldName, V fieldValue)
Write a field into JSON event layout.- Parameters:
writer- JSON writer to use.fieldName- Name of the field to write.fieldValue- Value of the field to write.
-
addExclude
public void addExclude(java.lang.String key)
-
addInclude
public void addInclude(java.lang.String key)
-
getPrefix
public java.lang.String getPrefix()
-
setPrefix
public void setPrefix(java.lang.String prefix)
-
isNoPrefix
public boolean isNoPrefix()
-
setNoPrefix
public void setNoPrefix(boolean noPrefix)
-
-