org.oclc.da.gdfr.registryprototype.logging
Class Logger

java.lang.Object
  extended by org.oclc.da.gdfr.registryprototype.logging.Logger

public class Logger
extends java.lang.Object

This class isolates the Digital Archive code from the logging facility by hiding all configuration code related to that external facility and by providing utility methods for most used exception reporting cases. The caller code is required to include information about the class reporting this error, the method is which the error was caught, possibly a tagged location inside the method (to eliminate any ambiguity), and the exception object itself from which the class type and its internal message is extracted and logged.


Field Summary
static java.math.BigInteger ERROR
           
static java.math.BigInteger WARN
           
 
Constructor Summary
protected Logger()
          Private constructor
 
Method Summary
 void log(int code, java.math.BigInteger type, java.lang.Object reporter, java.lang.String reporterMethod, java.lang.String reporterLocation, java.lang.Throwable ex)
          Utility method to log an system exception.
 void log(int code, java.lang.Object reporter, java.lang.String reporterMethod, java.lang.String reporterLocation, java.lang.Throwable ex)
          Utility method that simplifies error reporting for known classes such as IfsException and RemoteException.
 void log(java.lang.Object reporter, java.lang.String reporterMethod, java.lang.String reporterLocation, RegistryException ex)
          Utility method that simplifies error reporting for RegistryException s especially those that have multiple exception messages.
 void log(java.lang.Object reporter, java.lang.String reporterMethod, java.lang.String reporterLocation, RegistrySystemException ex)
          Utility method that simplifies error reporting for RegistrySystemException s especially those that have multiple exception messages.
static Logger newInstance()
          Create a new instance of the Logger
 java.lang.Throwable resolveException(java.lang.Throwable ex)
          Utility method that simplifies error reporting for regularly used exception classes such as IfsException and RemoteException.
If (ex instanceof IfsException): This method will recursively go through all the nested exceptions ignoring all IFS-30002 errors until a different IFS error code is found or a different exception type is found.
 void trace(java.lang.Object reporter, java.lang.String reporterMethod, java.lang.String reporterLocation)
          Utility method to log a trace any message.
 void trace(java.lang.Object reporter, java.lang.String reporterMethod, java.lang.String reporterLocation, int code, java.lang.String[] args)
          Utility method to log a trace message.
 void trace(java.lang.Object reporter, java.lang.String reporterMethod, java.lang.String reporterLocation, java.lang.String[] messageParts)
          Utility method to log a trace any message.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

WARN

public static final java.math.BigInteger WARN

ERROR

public static final java.math.BigInteger ERROR
Constructor Detail

Logger

protected Logger()
Private constructor

Method Detail

newInstance

public static Logger newInstance()
Create a new instance of the Logger

Returns:
A new logger instance.

log

public void log(int code,
                java.lang.Object reporter,
                java.lang.String reporterMethod,
                java.lang.String reporterLocation,
                java.lang.Throwable ex)
Utility method that simplifies error reporting for known classes such as IfsException and RemoteException. The execution of this method is equivalent to calling the log method with a Throwable argument and an Logger.ERROR error level, using the return from resolveException().

Parameters:
code - The error id of this error already defined in DAExceptionCodes. It should be the error code in the corresponding DAException that is thrown right after this logging method completes.
reporter - The object reporting this error - required.
reporterMethod - The method name where this error was caught - required.
reporterLocation - A location tag in the method where this error was caught - optional.
ex - The Throwable to be reported.

log

public void log(java.lang.Object reporter,
                java.lang.String reporterMethod,
                java.lang.String reporterLocation,
                RegistryException ex)
Utility method that simplifies error reporting for RegistryException s especially those that have multiple exception messages. A level of Logger.WARN is used.

Parameters:
reporter - The object reporting this error - required.
reporterMethod - The method name where this error was caught - required.
reporterLocation - A location tag in the method where this error was caught - optional.
ex - The DAException to be reported.

log

public void log(java.lang.Object reporter,
                java.lang.String reporterMethod,
                java.lang.String reporterLocation,
                RegistrySystemException ex)
Utility method that simplifies error reporting for RegistrySystemException s especially those that have multiple exception messages. A level of Logger.ERROR is used.

Parameters:
reporter - The object reporting this error - required.
reporterMethod - The method name where this error was caught - required.
reporterLocation - A location tag in the method where this error was caught - optional.
ex - The DASystemException to be reported.

log

public void log(int code,
                java.math.BigInteger type,
                java.lang.Object reporter,
                java.lang.String reporterMethod,
                java.lang.String reporterLocation,
                java.lang.Throwable ex)
Utility method to log an system exception. Note that the Throwable argument is NOT checked for wrapped exceptions, as is the case with IfsException and RemoteException. This throwable is logged as such. If you want to log the core of the problem and not the wrapper exception, use the method above.

Parameters:
code - The error id of this error already defined in DAExceptionCodes. It should be the error code in the corresponding DAException that is thrown right after this logging method completes.
type - One of ExceptionLogger.WARN or ExceptionLogger.ERROR. The first translates to an iSoft Incident of type Incident.WARNING, the latter to one of type Incident.CRITICAL. If the code is not one of WARN or ERROR, the method assigns ERROR as default.
reporter - The object reporting this error - required.
reporterMethod - The method name where this error was caught - required.
reporterLocation - A location tag in the method where this error was caught - optional.
ex - The Throwable to be reported.

trace

public void trace(java.lang.Object reporter,
                  java.lang.String reporterMethod,
                  java.lang.String reporterLocation,
                  int code,
                  java.lang.String[] args)
Utility method to log a trace message. The name of the message is always TRACE and the type is translated to Incident.INFO.
Note that by using string arrays to contain parts of the message is significantly faster than concatenating the message prior to executing this method since the trace message is only logged on debugging is turned on.

Parameters:
reporter - The object reporting this error - required.
reporterMethod - The method name where this error was caught - required.
reporterLocation - A location tag in the method where this error was caught - optional.
code - A message string that conforms to the pattern substitution rules documented in DAExceptionCodes class.
args - The arguments to be substituted in the pattern.

trace

public void trace(java.lang.Object reporter,
                  java.lang.String reporterMethod,
                  java.lang.String reporterLocation,
                  java.lang.String[] messageParts)
Utility method to log a trace any message. The name of the message is always TRACE and the type is translated to Incident.INFO.
Note that by using string arrays to contain parts of the message is significantly faster than concatenating the message prior to executing this method since the trace message is only logged on debugging is turned on. This is expecially helpful when the parts of the message come from different variables, objects or cases.

Parameters:
reporter - The object reporting this error - required.
reporterMethod - The method name where this error was caught - required.
reporterLocation - A location tag in the method where this error was caught - optional.
messageParts - The parts of the message to be traced - optional.

trace

public void trace(java.lang.Object reporter,
                  java.lang.String reporterMethod,
                  java.lang.String reporterLocation)
Utility method to log a trace any message. The name of the message is always TRACE and the type is translated to Incident.INFO.
Note that by using string arrays to contain parts of the message is significantly faster than concatenating the message prior to executing this method since the trace message is only logged on debugging is turned on. This is expecially helpful when the parts of the message come from different variables, objects or cases.

Parameters:
reporter - The object reporting this error - required.
reporterMethod - The method name where this error was caught - required.
reporterLocation - A location tag in the method where this error was caught - optional.

resolveException

public java.lang.Throwable resolveException(java.lang.Throwable ex)
Utility method that simplifies error reporting for regularly used exception classes such as IfsException and RemoteException.
If (ex instanceof IfsException): This method will recursively go through all the nested exceptions ignoring all IFS-30002 errors until a different IFS error code is found or a different exception type is found. If the argument has no nested exceptions, the method returns the exception passed in the argument.
If (ex instanceof RemoteException): This method will look at the nested exception to determine which exception to return. If the argument has no nested exception, the method returns the exception passed in the argument.

Parameters:
ex - The Throwable to be searched.
Returns:
The nested throwable that was at the core of the problem when the class in the argument was thrown.


Copyright © 2008 OCLC Online Computer Library Center, Inc.. All Rights Reserved.