synergy.debug
Class Debug

java.lang.Object
  |
  +--synergy.debug.Debug

public class Debug
extends java.lang.Object

The debug class provides an alternative to the System.out.println and print methods. It provides a means for the Quality Assurance engineers to determine problem areas in the code and focus their testing on that section.

Debug.prp

The debug properties are stored in a text file by the name of "Debug.prp" which must be located in the same directory as the java VM was run in. This file will provide a means of setting various paramatters for the Debug class.

When the doPrintln or print method is called, there is an associated debug level provided with it. By default, the debugLevel is 0. This level is used to determine the importance of the statement. The default level indicates that it is simply some verbose processing by the developer and does not necessarily indicate a problem area.

The valid values for this include:

0: print level (verbose processing)

1: warning level (problem area in code, requires attention)

2: error level (a genuine error has occurred in the code)

3: fatal error (a fatal error has occured and the system is exitting)

There are a number of options that can be set for the Debug class in the Debug.prp file. These include:

timestampformat = dd.MM.yyyy hh.mm.ss

This specifies what format the time stamp should take on, the above example indicates that the time stamp will be in the form day/month/year hours/minutes/seconds. The following is an excerpt from the java.text.SimpleDateFormat java documentation:

To specify the time format use a time pattern string. In this pattern, all ASCII letters are reserved as pattern letters, which are defined as the following:

 Symbol   Meaning                 Presentation        Example
 ------   -------                 ------------        -------
 G        era designator          (Text)              AD
 y        year                    (Number)            1996
 M        month in year           (Text & Number)     July & 07
 d        day in month            (Number)            10
 h        hour in am/pm (1~12)    (Number)            12
 H        hour in day (0~23)      (Number)            0
 m        minute in hour          (Number)            30
 s        second in minute        (Number)            55
 S        millisecond             (Number)            978
 E        day in week             (Text)              Tuesday
 D        day in year             (Number)            189
 F        day of week in month    (Number)            2 (2nd Wed in July)
 w        week in year            (Number)            27
 W        week in month           (Number)            2
 a        am/pm marker            (Text)              PM
 k        hour in day (1~24)      (Number)            24
 K        hour in am/pm (0~11)    (Number)            0
 z        time zone               (Text)              Pacific Standard Time
 '        escape for text         (Delimiter)
 ''       single quote            (Literal)           '
 

Examples Using the US Locale:

 Format Pattern                         Result
 --------------                         -------
 "yyyy.MM.dd G 'at' hh:mm:ss z"    ->>  1996.07.10 AD at 15:08:56 PDT
 "EEE, MMM d, ''yy"                ->>  Wed, July 10, '96
 "h:mm a"                          ->>  12:08 PM
 "hh 'o''clock' a, zzzz"           ->>  12 o'clock PM, Pacific Daylight Time
 "K:mm a, z"                       ->>  0:00 PM, PST
 "yyyyy.MMMMM.dd GGG hh:mm aaa"    ->>  1996.July.10 AD 12:08 PM
 

debuglevel = 0

The debug level indicates what sort of errors to display. As mentioned above, the debug level of a print statement can have a given value, by setting the debug level in the properties file, you can specify what sort of errors you want to see. For example, a debug level of 1 would show only warning level, error and fatal error messages, a debug level of 2 would show all error messages and fatal error messages. NB. You can not turn off fatal error messages.


Field Summary
static java.lang.String dateFormat
          The default date format
static java.text.SimpleDateFormat dateFormatter
          The date formatter class
static int debugLevel
          The debug level this is at
static int kErrorLevel
          Highly important debug levels
static int kFatalLevel
          Anything above this value will always be logged
static int kPrintLevel
          The lowest level debug level, least important
static java.lang.String kPropertiesFileName
          The name of the file with the debug properties in it
static java.lang.String kRunLevel
          The constant name of the run level property
static java.lang.String kTimeStampFormat
          The constant name of the time stamp format property
static int kWarningLevel
          Moderately important debug levels
 
Constructor Summary
Debug()
           
 
Method Summary
static void doInitialisation()
          This method will initialise the Debug class with the defaults, or the text file provided.
static void doPrint(java.lang.String message)
          Performs the same functionality as the System.out.println() method but also logs the message in a log file.
static void doPrint(java.lang.String message, int runLevel)
          This writes the given message to standard out and provides the runLevel in which the debug message should be presented.
static void doPrintln(java.lang.String message)
          Performs the same functionality as the System.out.println() method but also logs the message in a log file.
static void doPrintln(java.lang.String message, int runLevel)
          This writes the given message to standard out and provides the runLevel in which the debug message should be presented.
static boolean isInitialised()
          This method will indicate whether the Debug class has been intialised.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

debugLevel

public static int debugLevel
The debug level this is at

kPrintLevel

public static final int kPrintLevel
The lowest level debug level, least important

kWarningLevel

public static final int kWarningLevel
Moderately important debug levels

kErrorLevel

public static final int kErrorLevel
Highly important debug levels

kFatalLevel

public static final int kFatalLevel
Anything above this value will always be logged

dateFormat

public static java.lang.String dateFormat
The default date format

dateFormatter

public static java.text.SimpleDateFormat dateFormatter
The date formatter class

kPropertiesFileName

public static final java.lang.String kPropertiesFileName
The name of the file with the debug properties in it

kRunLevel

public static final java.lang.String kRunLevel
The constant name of the run level property

kTimeStampFormat

public static final java.lang.String kTimeStampFormat
The constant name of the time stamp format property
Constructor Detail

Debug

public Debug()
Method Detail

doPrintln

public static void doPrintln(java.lang.String message,
                             int runLevel)
This writes the given message to standard out and provides the runLevel in which the debug message should be presented.
Parameters:
message - The message to log and print
runLevel - The debug level to log the message in

doPrintln

public static void doPrintln(java.lang.String message)
Performs the same functionality as the System.out.println() method but also logs the message in a log file.
Parameters:
message - The message to output

doPrint

public static void doPrint(java.lang.String message)
Performs the same functionality as the System.out.println() method but also logs the message in a log file.
Parameters:
message - The message to output

doPrint

public static void doPrint(java.lang.String message,
                           int runLevel)
This writes the given message to standard out and provides the runLevel in which the debug message should be presented.
Parameters:
message - The message to log and print
runLevel - The debug level to log the message in

doInitialisation

public static void doInitialisation()
This method will initialise the Debug class with the defaults, or the text file provided.

isInitialised

public static boolean isInitialised()
This method will indicate whether the Debug class has been intialised.