|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.ObjectJICSCore.MessageHandler
public class MessageHandler
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");
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 |
---|
private boolean DebugMode
public int Facility
The default facility is SyslogDefs.LOG_USER | SyslogDefs.LOG_PID
public int Priority
public java.lang.String HostName
public java.lang.String ProcessName
boolean DisplayDate
Constructor Detail |
---|
public MessageHandler()
Method Detail |
---|
public void initialiseMessageHandler(boolean DisplayDate)
DisplayDate
- True if all messages included into the
syslog will be prefixed with the current date and timepublic void reportDebug(java.lang.String Message)
Message
- - The string representation of the message to be put
into the logpublic void reportInfo(java.lang.String Message)
Message
- - The string representation of the message to be put
into the logpublic void reportError(java.lang.String Message)
Message
- - The string representation of the message to be put
into the logpublic void reportAlarm(java.lang.String Message)
Message
- - The string representation of the message to be put
into the logprivate void sendErrorToSyslog(int Level, java.lang.String Message)
Level
- - This is the priority level of the message when put into
the syslogMessage
- - The string representation of the message to be put
into the logpublic void setDebugMode(boolean EnableDebug)
EnableDebug
- - Set to true in order to indicate that debug
should be output
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |