uk.org.lidalia.sysoutslf4j.context.exceptionhandlers
Interface ExceptionHandlingStrategyFactory

All Known Implementing Classes:
LogPerLineExceptionHandlingStrategyFactory

public interface ExceptionHandlingStrategyFactory

Interface for factories that create ExceptionHandlingStrategies to allow users to provide their own mechanism for handling the difficult problem of capturing the output of Throwable.printStacktrace() and turning it into logging events.

The default implementation is LogPerLineExceptionHandlingStrategyFactory which returns an ExceptionHandlingStrategy that simply logs each line of the stack trace as a separate logging event.


Method Summary
 ExceptionHandlingStrategy makeExceptionHandlingStrategy(LogLevel logLevel, PrintStream originalPrintStream)
          This method will be called twice for each context that is sent to SLF4J, once each to return an ExceptionHandlingStrategy for the new System.out and System.err print streams.
It is called with the LogLevel of the SLF4JPrintStream and the original System output PrintStream that is being replaced, so that ExceptionHandlingStrategies can have direct access to the console if they wish.
 

Method Detail

makeExceptionHandlingStrategy

ExceptionHandlingStrategy makeExceptionHandlingStrategy(LogLevel logLevel,
                                                        PrintStream originalPrintStream)
This method will be called twice for each context that is sent to SLF4J, once each to return an ExceptionHandlingStrategy for the new System.out and System.err print streams.
It is called with the LogLevel of the SLF4JPrintStream and the original System output PrintStream that is being replaced, so that ExceptionHandlingStrategies can have direct access to the console if they wish.

Parameters:
logLevel - The LogLevel of the parent PrintStream (by default INFO for System.out and ERROR for System.err)
originalPrintStream - The original System output PrintStream providing direct access to the console
Returns:
an ExceptionHandlingStrategy that will be called with each line of an Exception that is printed using Throwable.printStacktrace() or Throwable.printStacktrace(System.out)


Copyright © 2010. All Rights Reserved.