JICSCore
Class MessageHandler

java.lang.Object
  extended by JICSCore.MessageHandler

public class MessageHandler
extends java.lang.Object

This class wraps up the syslog classes into a standard method of accessing the syslog which is applicable to the way that we use the syslog here at the ING.

The methods provided allow the user to enter messages into the syslog as INFO, ERROR and DEBUG messages. There is also the option to write a message into the syslog such that it will cause an alarm in the talker log. An example of the initialisation sequence of the class follows

 
 import com.ice.syslog.*;
 import JICSCore.*;
 
 MessageHandler messageHandler = new MessageHandler();

 messageHandler.HostName = "localhost";
 messageHandler.ProcessName = "PFIPController";
 
 // Log the errors to stderr and include the PID in the messages 
 
 messageHandler.Facility = SyslogDefs.LOG_USER | SyslogDefs.LOG_PERROR | SyslogDefs.LOG_PID; 
 
 // Initialise the syslog classes and request that we include the date in the messages
 
 messageHandler.initialiseMessageHandler(true);
 
 // Enable debug output in the application 
        
 messageHandler.setDebugMode(true);
 
 // This will put an informational message into the syslog
 
 messageHandler.reportInfo("PFIP 4MS Controller Version Starting Up");
 
 // This will put a warning  message into the syslog
 
 messageHandler.reportError("This is a warning message");
 
 // This will put a debug message into the syslog, this will only be put into the syslog
 // if the debug is enabled
 
 messageHandler.reportDebug("This is debug message");
 
 // This will put an alarm message into the syslog
 
 messageHandler.reportAlarm("This is an alarm");
 
 

Author:
Craige Bevil

Field Summary
private  boolean DebugMode
          This indicates whether or not debug messages will be output The default is not to output debug messages, they must be enabled by the instantiator.
(package private)  boolean DisplayDate
          Indicates whether or not the date should be displayed in the output, by default the date is not included in the output to syslog.
 int Facility
          This is the default facility which will be used for reporting errors.
 java.lang.String HostName
          This is the name of the host upon which the syslog daemon that we want to connect resides.
 int Priority
          This is the default priority that will be used when reporting error.
 java.lang.String ProcessName
          This is the name of the process which will be associated with the message.
 
Constructor Summary
MessageHandler()
           
 
Method Summary
 void initialiseMessageHandler(boolean DisplayDate)
          This is should be called to initialise the message handler and after all of the syslog configuration has been performed.
 void reportAlarm(java.lang.String Message)
          This method will used for reporting an error message into the syslog such that it will be reported as an alarm by the talker log.
 void reportDebug(java.lang.String Message)
          This method will used for reporting a debug message into the syslog if DebugMode has been enabled.
 void reportError(java.lang.String Message)
          This method will used for reporting an error message into the syslog.
 void reportInfo(java.lang.String Message)
          This method will used for reporting an INFO message into the syslog.
private  void sendErrorToSyslog(int Level, java.lang.String Message)
          This method will used for reporting a message into the syslog.
 void setDebugMode(boolean EnableDebug)
          Enable or suppress the output of debug messages into the syslog.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DebugMode

private boolean DebugMode
This indicates whether or not debug messages will be output The default is not to output debug messages, they must be enabled by the instantiator.


Facility

public int Facility
This is the default facility which will be used for reporting errors. This should be a logical OR of one or more of the constants that are described in the syslog package (SyslogDefs.LOG_USER, SyslogDefs.LOG_PID etc.)

The default facility is SyslogDefs.LOG_USER | SyslogDefs.LOG_PID


Priority

public int Priority
This is the default priority that will be used when reporting error. A logical OR of one or more priorities which are described in the Sysdef class. The default priority is SyslogDefs.LOG_INFO


HostName

public java.lang.String HostName
This is the name of the host upon which the syslog daemon that we want to connect resides. By default messages are sent to the syslog host running on the local machine


ProcessName

public java.lang.String ProcessName
This is the name of the process which will be associated with the message. By default this is set to Unknown


DisplayDate

boolean DisplayDate
Indicates whether or not the date should be displayed in the output, by default the date is not included in the output to syslog.

Constructor Detail

MessageHandler

public MessageHandler()
Method Detail

initialiseMessageHandler

public void initialiseMessageHandler(boolean DisplayDate)
This is should be called to initialise the message handler and after all of the syslog configuration has been performed.

Parameters:
DisplayDate - True if all messages included into the syslog will be prefixed with the current date and time

reportDebug

public void reportDebug(java.lang.String Message)
This method will used for reporting a debug message into the syslog if DebugMode has been enabled.

Parameters:
Message - - The string representation of the message to be put into the log

reportInfo

public void reportInfo(java.lang.String Message)
This method will used for reporting an INFO message into the syslog.

Parameters:
Message - - The string representation of the message to be put into the log

reportError

public void reportError(java.lang.String Message)
This method will used for reporting an error message into the syslog. In the talker log this message will be highlighted as yellow.

Parameters:
Message - - The string representation of the message to be put into the log

reportAlarm

public void reportAlarm(java.lang.String Message)
This method will used for reporting an error message into the syslog such that it will be reported as an alarm by the talker log.

Parameters:
Message - - The string representation of the message to be put into the log

sendErrorToSyslog

private void sendErrorToSyslog(int Level,
                               java.lang.String Message)
This method will used for reporting a message into the syslog. The other methods which are public to the outside world wrap up calls to this method.

Parameters:
Level - - This is the priority level of the message when put into the syslog
Message - - The string representation of the message to be put into the log

setDebugMode

public void setDebugMode(boolean EnableDebug)
Enable or suppress the output of debug messages into the syslog.

Parameters:
EnableDebug - - Set to true in order to indicate that debug should be output