tuwien.auto.calimero.log
Class ErrorHandler

java.lang.Object
  extended by tuwien.auto.calimero.log.ErrorHandler

public class ErrorHandler
extends java.lang.Object

An error handler is invoked on problems of a log writer which are not handled by the writer itself.

Such problems shouldn't get logged using another log writer, to prevent the possibility of a fault / failure chain, and shouldn't lead to disruption of the logging system at a whole.
Moreover, log writer errors most certainly can't be returned back to the owner of the writer responsible for handling the errors. And handling errors directly in log services can rarely be done in a satisfying way.
So the associated error handler is used for such error events.
The handler itself might be adapted to the application needs. For example, an overridden error(LogWriter, String, Exception) might close the log writer the error originated from.

See Also:
LogWriter

Field Summary
protected  int invocations
          Counter how often error() was called (without abort).
protected  int maxInvocations
          Sets the maximum number error(LogWriter, String, Exception) should handle error events.
 
Constructor Summary
ErrorHandler()
          Creates a new error handler.
 
Method Summary
 void error(LogWriter source, java.lang.String msg, java.lang.Exception e)
          Invoked on a log writer error event.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

invocations

protected int invocations
Counter how often error() was called (without abort).


maxInvocations

protected int maxInvocations
Sets the maximum number error(LogWriter, String, Exception) should handle error events.

The number should be set reasonably low to prevent a continued handling of repeated errors of the same source.
Initialized to 5 by default.

Constructor Detail

ErrorHandler

public ErrorHandler()
Creates a new error handler.

Method Detail

error

public void error(LogWriter source,
                  java.lang.String msg,
                  java.lang.Exception e)
Invoked on a log writer error event.

The default behavior used here prints the logging source and the error message to the system standard error stream (System.err). If an exception object is given, the exception and the last method calls of the log writer leading to the error are also printed.
Only predefined maximum invocations are handled, subsequent calls are ignored.

Parameters:
source - the log writer the error originated from
msg - message describing the error
e - exception related to the error, may be null