logging
Class LogHolder

java.lang.Object
  extended by logging.LogHolder

public final class LogHolder
extends java.lang.Object

This class stores the Log instance.


Field Summary
static int DETAIL_LEVEL_HIGH
          prints the log message, package, classname, method name and the source line of the log message; this enables some IDEs to jump to the log source by clicking on the message line
static int DETAIL_LEVEL_HIGHEST
          additionally prints the whole stack trace of an error log if available
static int DETAIL_LEVEL_LOWER
          prints the log message, the class name and the source line of the log message
static int DETAIL_LEVEL_LOWEST
          prints the log message only
private static java.lang.String[] DETAIL_LEVEL_NAMES
           
private static int LINE_LENGTH_HIGH_DETAIL
           
private static int LINE_LENGTH_HIGHEST_DETAIL
           
private static java.lang.String LOGGED_THROWABLE
           
private static int m_messageDetailLevel
          The current detail level of all log messages.
private static LogHolder ms_logHolderInstance
          Stores the instance of LogHolder (Singleton).
private static Log ms_logInstance
          Stores the Log instance.
private static java.lang.String TRACED_LOG_MESSAGE
           
 
Constructor Summary
private LogHolder()
          This creates a new instance of LogHolder.
 
Method Summary
 void finalize()
           
private static java.lang.String getCallingClassFile(boolean a_bSkipOwnClass)
          Returns the filename and line number of the calling method (from outside this class) in the form (class.java:) .
private static java.lang.String getCallingMethod(boolean a_bSkipOwnClass)
          Returns the name, class, file and line number of the calling method (from outside this class) in the form package.class.method(class.java:) .
static int getDetailLevel()
          Gets the detail level of all log messages.
static int getDetailLevelCount()
           
static java.lang.String getDetailLevelName(int a_detail)
           
private static Log getLogInstance()
          Returns the logInstance.
static boolean isLogged(int a_logLevel, int a_logType)
           
static void log(int logLevel, int logType, java.lang.String message)
          Write the log data to the Log instance.
static void log(int logLevel, int logType, java.lang.String message, boolean a_bAddCallingClass)
          Write the log data to the Log instance.
static void log(int a_logLevel, int a_logType, java.lang.String a_message, java.lang.Throwable a_throwable)
          Write the log data for a Throwable to the Log instance.
static void log(int a_logLevel, int a_logType, java.lang.Throwable a_throwable)
          Write the log data for a Throwable to the Log instance.
static boolean setDetailLevel(int a_messageDetailLevel)
          Sets the detail level of all log messages.
static void setLogInstance(Log logInstance)
          Sets the logInstance.
 
Methods inherited from class java.lang.Object
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DETAIL_LEVEL_LOWEST

public static final int DETAIL_LEVEL_LOWEST
prints the log message only

See Also:
Constant Field Values

DETAIL_LEVEL_LOWER

public static final int DETAIL_LEVEL_LOWER
prints the log message, the class name and the source line of the log message

See Also:
Constant Field Values

DETAIL_LEVEL_HIGH

public static final int DETAIL_LEVEL_HIGH
prints the log message, package, classname, method name and the source line of the log message; this enables some IDEs to jump to the log source by clicking on the message line

See Also:
Constant Field Values

DETAIL_LEVEL_HIGHEST

public static final int DETAIL_LEVEL_HIGHEST
additionally prints the whole stack trace of an error log if available

See Also:
Constant Field Values

DETAIL_LEVEL_NAMES

private static final java.lang.String[] DETAIL_LEVEL_NAMES

TRACED_LOG_MESSAGE

private static final java.lang.String TRACED_LOG_MESSAGE
See Also:
Constant Field Values

LOGGED_THROWABLE

private static final java.lang.String LOGGED_THROWABLE
See Also:
Constant Field Values

LINE_LENGTH_HIGH_DETAIL

private static final int LINE_LENGTH_HIGH_DETAIL
See Also:
Constant Field Values

LINE_LENGTH_HIGHEST_DETAIL

private static final int LINE_LENGTH_HIGHEST_DETAIL
See Also:
Constant Field Values

ms_logHolderInstance

private static LogHolder ms_logHolderInstance
Stores the instance of LogHolder (Singleton).


m_messageDetailLevel

private static int m_messageDetailLevel
The current detail level of all log messages.


ms_logInstance

private static Log ms_logInstance
Stores the Log instance.

Constructor Detail

LogHolder

private LogHolder()
This creates a new instance of LogHolder. This is only used for setting some values. Use LogHolder.getInstance() for getting an instance of this class.

Method Detail

finalize

public void finalize()
              throws java.lang.Throwable
Overrides:
finalize in class java.lang.Object
Throws:
java.lang.Throwable

getDetailLevelCount

public static int getDetailLevelCount()

getDetailLevelName

public static java.lang.String getDetailLevelName(int a_detail)

setDetailLevel

public static boolean setDetailLevel(int a_messageDetailLevel)
Sets the detail level of all log messages. Use one of the class constants to set it. The detail levels range from 0 (DETAIL_LEVEL_LOWEST) to DETAIL_LEVEL_HIGHEST. The higher the detail level, the more detailed information will be written to the logs.

Parameters:
a_messageDetailLevel - the detail level of all log messages

getDetailLevel

public static int getDetailLevel()
Gets the detail level of all log messages.

Returns:
a_messageDetailLevel the detail level of all log messages

log

public static void log(int a_logLevel,
                       int a_logType,
                       java.lang.Throwable a_throwable)
Write the log data for a Throwable to the Log instance.

Parameters:
a_logLevel - The log level (see constants in class LogLevel).
a_logType - The log type (see constants in class LogType).
a_throwable - a Throwable to log

log

public static void log(int a_logLevel,
                       int a_logType,
                       java.lang.String a_message,
                       java.lang.Throwable a_throwable)
Write the log data for a Throwable to the Log instance.

Parameters:
a_logLevel - The log level (see constants in class LogLevel).
a_logType - The log type (see constants in class LogType).
a_message - an (optional) log message
a_throwable - a Throwable to log

log

public static void log(int logLevel,
                       int logType,
                       java.lang.String message,
                       boolean a_bAddCallingClass)
Write the log data to the Log instance.

Parameters:
logLevel - The log level (see constants in class LogLevel).
logType - The log type (see constants in class LogType).
message - The message to log.
a_bAddCallingClass - true if not only the name and class of the current method should be logged but also the name of the method in the class that has called this method; false if only the name of the current method should be logged (default)

log

public static void log(int logLevel,
                       int logType,
                       java.lang.String message)
Write the log data to the Log instance.

Parameters:
logLevel - The log level (see constants in class LogLevel).
logType - The log type (see constants in class LogType).
message - The message to log.

setLogInstance

public static void setLogInstance(Log logInstance)
Sets the logInstance.

Parameters:
logInstance - The instance of a Log implementation.

getLogInstance

private static Log getLogInstance()
Returns the logInstance. If the logInstance is not set, there is a new DummyLog instance returned.

Returns:
The current logInstance.

isLogged

public static boolean isLogged(int a_logLevel,
                               int a_logType)

getCallingClassFile

private static java.lang.String getCallingClassFile(boolean a_bSkipOwnClass)
Returns the filename and line number of the calling method (from outside this class) in the form (class.java:) .

Parameters:
a_bSkipOwnClass - if true, the true calling method is skipped and the class file of the first method in the stack trace of the calling class that is in another class than itself is returned; if false, the class file of the calling method is returned (default)
Returns:
the filename and line number of the calling method

getCallingMethod

private static java.lang.String getCallingMethod(boolean a_bSkipOwnClass)
Returns the name, class, file and line number of the calling method (from outside this class) in the form package.class.method(class.java:) . This method does need some processing time, as an exception with the stack trace is generated.

Parameters:
a_bSkipOwnClass - if true, the true calling method is skipped and the caller of the first method in the stack trace of calling method that is in another class than itself is returned; if false, the calling method is returned (default)
Returns:
the name, class and line number of the calling method