Package com.illumon.iris.db
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 Summary
ConstructorsConstructorDescriptionTableWriterLogInterceptor(ProcessEventLogFormat2Logger logger, String host, String process, String processInfoId, UserContext userContext) Create a TableWriterLogInterceptor instance -
Method Summary
Modifier and TypeMethodDescriptionfinal voidUsed by the logging infrastructure, not intended for user callsstatic StringgenerateMessage(com.fishlib.base.log.LogOutput logOutput) Given the logOutput parameter, generate the string message.voidsetUserContext(UserContext userContext) Update the authenticated and effective users for all log operations
-
Constructor Details
-
TableWriterLogInterceptor
public TableWriterLogInterceptor(@NotNull ProcessEventLogFormat2Logger logger, String host, String process, String processInfoId, UserContext userContext) Create a TableWriterLogInterceptor instance- Parameters:
logger- the ProcessEventLog to which events will be writtenhost- hostname to be used for loggingprocess- process name to be used for logginguserContext- user context for logging, null if not known
-
-
Method Details
-
setUserContext
Update the authenticated and effective users for all log operations- Parameters:
userContext- user context for logging
-
element
Used by the logging infrastructure, not intended for user calls- Specified by:
elementin interfacecom.fishlib.io.log.LogSink.Interceptor<T extends com.fishlib.io.log.LogSink.Element>- Throws:
IOException
-
generateMessage
Given the logOutput parameter, generate the string message.- Parameters:
logOutput- the logOutput we are intercepting- Returns:
- a String representation of the log output
-