logahawk.listeners
Class FailSafeListener
java.lang.Object
logahawk.listeners.ProxyListener
logahawk.listeners.FailSafeListener
- All Implemented Interfaces:
- Listener
@ThreadSafe
public class FailSafeListener
- extends ProxyListener
A special Listener designed to handle exceptions thrown by the Listener.log(LogMeta, String) method.
The FailSafeListener encapsulates two Listeners, a primary and a backup. When Listener.log(LogMeta, String) is called on this class, the primary Listener's log() is called. If no
exception is thrown, nothing special happens. But if an exception is thrown, the log is re-tried on the backup
Listener.
Additional notes:
- This Listener will catch any Throwable thrown from the primary Listener, not just Exceptions.
- If the primary Listener throws, the original message and Exception will be logged to the backup
Listener.
- Multiple FailSafeListeners can be chained together if there are multiple Listeners that might
throw.
- See Also:
SafeListener
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
backup
protected final Listener backup
logMetaProvider
protected final LogMetaProvider logMetaProvider
- Used only when
backup is used.
FailSafeListener
public FailSafeListener(Listener primary,
Listener backup,
LogMetaProvider logMetaProvider)
log
public void log(LogMeta meta,
String text)
- Description copied from interface:
Listener
- Logs the provided statement.
Normally this method should not throw any exceptions. If exceptions are expected it is recommend to wrap this
Listener with a FailSafeListener.