Class TableWriterLogInterceptor<T extends com.fishlib.io.log.LogSink.Element>

java.lang.Object
com.illumon.iris.db.TableWriterLogInterceptor<T>
All Implemented Interfaces:
com.fishlib.io.log.LogSink.Interceptor<T>

public class TableWriterLogInterceptor<T extends com.fishlib.io.log.LogSink.Element>
extends Object
implements com.fishlib.io.log.LogSink.Interceptor<T>
Interceptor to write log entries to a persistent log. This is intended to be added to an existing log instance, so that log statements can be written to the Iris database. To use: 1. Create a standard Iris log. final Logger log = ... 2. Create and initialize a ProcessEventFormat1LogLogger. For example: final ProcessEventFormat1LogLogger processEventLogger = IntradayLoggerBuilder.createProcessEventLogger(Configuration.getInstance(), "MyMainClass", log, false, "America/New_York")); 3. Add the interceptor which will intercept all log messages and write them to the ProcessLog. Assuming that HOST_NAME and PROCESS_NAME have been determined (these two statements can be combined but are broken out in this example for clarity - if a UserContext is available it can be used instead of the last null parameter): final TableWriterLogInterceptor processLogInterceptor = new TableWriterLogInterceptor(processEventLogLogger, HOST_NAME, PROCESS_NAME, null); log.getSink().addInterceptor(processLogInterceptor); 4. If they're not known at creation time, the user information can be added later: processLogInterceptor.setUserContext(userContext); After step 3, all intercepted entries are written to the log. If needed filtering can be added in the future; see TeeInterceptor for an example.
  • Constructor Details

    • TableWriterLogInterceptor

      public TableWriterLogInterceptor​(@NotNull ProcessEventLogFormat1Logger logger, String host, String process, com.fishlib.auth.UserContext userContext)
      Create a TableWriterLogInterceptor instance
      Parameters:
      logger - the ProcessEventLog to which events will be written
      host - hostname to be used for logging
      process - process name to be used for logging
      userContext - user context for logging, null if not known
  • Method Details

    • setUserContext

      public void setUserContext​(com.fishlib.auth.UserContext userContext)
      Update the authenticated and effective users for all log operations
      Parameters:
      userContext - user context for logging
    • element

      public final void element​(T element, com.fishlib.base.log.LogOutput logOutput) throws IOException
      Used by the logging infrastructure, not intended for user calls
      Specified by:
      element in interface com.fishlib.io.log.LogSink.Interceptor<T extends com.fishlib.io.log.LogSink.Element>
      Throws:
      IOException