Package de.aristaflow.adept2.util
Class LoggerTools
java.lang.Object
de.aristaflow.adept2.util.LoggerTools
Provides commonly used functionality for logging.
- Author:
- Patrick Schmidt
-
Method Summary
Modifier and TypeMethodDescriptionstatic LoggerReturns the appropriate logger for the given class.static LoggerReturns the appropriate logger for the given object.static StringgetLoggerName(Class<?> cls) Gets the name of the designated class for retrieving an appropriate logger.static voidlogUnhandledException(Throwable exception) Logs the given otherwise unhandled exception.static voidlogVirtualMachineErrorSafely(VirtualMachineError vme, String backupMsg) Logs the designated virtual machine error safely that is the error is logged as unhandled exception but problems occurring when logging are handled and swallowed if appropriate.
-
Method Details
-
getLoggerName
Gets the name of the designated class for retrieving an appropriate logger.- Parameters:
cls- The name of the class for which to get a logger name.- Returns:
- The appropriate logger name for the designated class.
-
getLogger
Returns the appropriate logger for the given class.getLoggerName(Class)is used to determine the name of the logger.- Parameters:
cls- the class for which to get the appropriate logger- Returns:
- the appropriate logger for the given class
-
getLogger
Returns the appropriate logger for the given object. Calling this method is equivalent to callingLoggerTools.getLogger(object.getClass()).- Parameters:
object- the object for which to get the appropriate logger- Returns:
- the appropriate logger for the given object
-
logUnhandledException
Logs the given otherwise unhandled exception. The purpose of this method is to prevent that exceptions go unnoticed (i.e. get swallowed completely or are logged to the Eclipse-specific log instead of appearing in our log. Places where this method should be called are e.g.WorkbenchAdvisor.eventLoopException(Throwable)of Eclipse RCP applications- TODO: where else?
- Parameters:
exception- the unhandled exception (Throwable) to be logged
-
logVirtualMachineErrorSafely
Logs the designated virtual machine error safely that is the error is logged as unhandled exception but problems occurring when logging are handled and swallowed if appropriate.
Before swallowing, aRuntimeExceptionwill be printed toSystem.err, while aVirtualMachineErrorwill print the designated string toSystem.err. No complex logic should take place in case of a secondVirtualMachineError. However, if this leads to anotherRuntimeExceptionorVirtualMachineError, this will be swallowed to prevent the calling thread from dying.- Parameters:
vme- A virtual machine error to be safely logged, that is the calling thread must survive under all circumstances.backupMsg- The message to be used in case a secondVirtualMachineErroroccurs while logging the designated error.
-