Package org.logevents.observers
Class AbstractHttpPostJsonLogEventObserver
- java.lang.Object
-
- org.logevents.core.AbstractFilteredLogEventObserver
-
- org.logevents.observers.AbstractBatchingLogEventObserver
-
- org.logevents.observers.AbstractHttpPostJsonLogEventObserver
-
- All Implemented Interfaces:
LogEventObserver
- Direct Known Subclasses:
MicrosoftTeamsLogEventObserver
,SlackLogEventObserver
public abstract class AbstractHttpPostJsonLogEventObserver extends AbstractBatchingLogEventObserver
Convenience superclass for observers that send JSON over HTTP
-
-
Field Summary
-
Fields inherited from class org.logevents.observers.AbstractBatchingLogEventObserver
defaultBatcher, executor, scheduledExecutorService, shutdownHook
-
-
Constructor Summary
Constructors Constructor Description AbstractHttpPostJsonLogEventObserver(URL url)
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description void
configureProxy(Configuration configuration)
protected abstract Map<String,Object>
formatBatch(LogEventBatch batch)
Override this method to customize how theLogEventBatch
will be formatted as JSON.Proxy
getProxy()
URL
getUrl()
protected String
postJson(Map<String,Object> jsonMessage)
Override this method to customize how to execute the HTTP Post request.void
processBatch(LogEventBatch batch)
protected void
sendBatch(LogEventBatch batch, Function<LogEventBatch,Map<String,Object>> formatter)
String
toString()
-
Methods inherited from class org.logevents.observers.AbstractBatchingLogEventObserver
configureBatching, configureMarkers, createBatcher, createMdcBatcher, createProcessor, doLogEvent, getBatcher, getBatcherFactory, getDefaultBatcher, getMarkerBatcher, processBatch
-
Methods inherited from class org.logevents.core.AbstractFilteredLogEventObserver
configureFilter, filteredOn, getCondition, getThreshold, isEnabled, logEvent, setCondition, setFilter, setThreshold, shouldLogEvent
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface org.logevents.LogEventObserver
isEnabled, stream, toList
-
-
-
-
Constructor Detail
-
AbstractHttpPostJsonLogEventObserver
public AbstractHttpPostJsonLogEventObserver(URL url)
-
-
Method Detail
-
getUrl
public URL getUrl()
-
getProxy
public Proxy getProxy()
-
configureProxy
public void configureProxy(Configuration configuration)
-
processBatch
public void processBatch(LogEventBatch batch)
- Specified by:
processBatch
in classAbstractBatchingLogEventObserver
-
sendBatch
protected void sendBatch(LogEventBatch batch, Function<LogEventBatch,Map<String,Object>> formatter)
-
postJson
protected String postJson(Map<String,Object> jsonMessage) throws IOException
Override this method to customize how to execute the HTTP Post request. For example, this is a good place to put authentication logic- Throws:
IOException
-
formatBatch
protected abstract Map<String,Object> formatBatch(LogEventBatch batch)
Override this method to customize how theLogEventBatch
will be formatted as JSON.
-
toString
public String toString()
- Overrides:
toString
in classAbstractBatchingLogEventObserver
-
-