synergy.debug
Class Log

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

public class Log
extends java.lang.Object

The log class will allow messages to be written to a log file. It provides a means of appending or overwriting a file depending on the conents of the properties file.

Debug.prp

There are three properties you can include in the Debug.prp properties file, which is the same file used by the Debug class.

overwrite = true

This indicates whether to overwrite any previous log files or append the new log information to the end of the last. The latter can be useful given that all logs are time stamped. If this property isn't supplied it defaults to overwriting.

logname = Debug01.log

This indicates that the file the logged data is saved in is called Debug01.log (in this example). If this property isn't supplied, it defaults to Debug.log

logdir = logfiles

This indicates the directory to put the log file. In this case it uses a directory caled logfiles. The default is the current directory (the directory the program was run from.)

messages = ErrorMessages.log

This provides the name of the file to use when looking for pre-defined error messages. The default is "Messages.log" if it is not specified here.

Messages.log

As stated above, the pre-defined error messages can be found in a file called "Messages.log" or whatever is specified in the Debug.prp file. The messages can be used to provide lengthy and detailed messages without having to write them each time they are used.

For example: To define a message called "ioerror" in the file as being the name of the message "An Input/Output error has ocurred, please shut-down and restart the system"

You would put the messages.log (or the name specified) file: ioerror = An Input/Output error has ocurred, please shut-down and restart the system

When the coder wishes to use this message, all they have to do is refer to it by the "ioerror" name.

eg. Log.doError("Short message", "ioerror", Debug.kErrorLevel);

The logged file will then include both the short message and the long message referred to be ioerror.


Constructor Summary
Log()
           
 
Method Summary
static void doError(java.lang.String message, int errorLevel)
          This will write the given error message to the log file along with the error level.
static void doError(java.lang.String message, java.lang.String messageEntry, int errorLevel)
          This will write the given error message to the log file along with the error level.
static void doFatalError(java.lang.String message)
          This will always write the fatal error message to the log file and exit the application no matter what the current run level is.
static void doInitialisation()
          This method will initialise the Debug class with the defaults, or the text file provided.
static void doPrintln(java.lang.String message)
          Places the given warning message into the log file if the current debug level allows it.
static void doWarning(java.lang.String warningMessage)
          Places the given warning message into the log file if the current debug level allows it.
static void doWarning(java.lang.String warningMessage, java.lang.String messageEntry)
          Places the given warning message into the log file if the current debug level allows it.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Log

public Log()
Method Detail

doInitialisation

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

doPrintln

public static void doPrintln(java.lang.String message)
Places the given warning message into the log file if the current debug level allows it.
Parameters:
warningMessage - The warning message

doError

public static void doError(java.lang.String message,
                           java.lang.String messageEntry,
                           int errorLevel)
This will write the given error message to the log file along with the error level. The error level is on par with the debug levels used elsewhere. That is to say, you can have an error of level Print, Warning, Error or Fatal. These are all defined in the Debug class

This version allows the coder to specify the name of a predefined message from the Messages.log file to be used as well.

Parameters:
message - The error message
errorLevel - The error level

doError

public static void doError(java.lang.String message,
                           int errorLevel)
This will write the given error message to the log file along with the error level. The error level is on par with the debug levels used elsewhere. That is to say, you can have an error of level Print, Warning, Error or Fatal. These are all defined in the Debug class
Parameters:
message - The error message
errorLevel - The error level

doFatalError

public static void doFatalError(java.lang.String message)
This will always write the fatal error message to the log file and exit the application no matter what the current run level is.
Parameters:
message - The message to log

doWarning

public static void doWarning(java.lang.String warningMessage,
                             java.lang.String messageEntry)
Places the given warning message into the log file if the current debug level allows it.

This version allows the coder to specify a predefined message in the Messages.log file by its title.

Parameters:
warningMessage - The warning message

doWarning

public static void doWarning(java.lang.String warningMessage)
Places the given warning message into the log file if the current debug level allows it.
Parameters:
warningMessage - The warning message