|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.util.TimerTask
JICSCore.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. Additional methods exist which allow a blocking time in seconds to be specified for a specific message. If a caller subsequently attempts to insert the same message into the syslog within the block time, the MessageHandler class will not insert the new message into the syslog. 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 java.util.Timer |
checkExpireMessageBlocksTimer
|
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. |
private boolean |
EngineeringMode
This indicates whether or not engineering messages will be output The default is not to output engineering messages, they must be enabled by the instantiator. |
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. |
private java.util.HashMap<Severity,java.util.HashMap<java.lang.Integer,java.lang.Long>> |
MessageExpiryTimes
Used to store the details of any message postponements. |
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()
Constructor |
Method Summary | |
---|---|
private void |
addMessageBlock(Severity severity,
java.lang.String message,
int delayInSecs)
Add a message postponement for a specific message |
private boolean |
checkForMessageBlock(Severity severity,
java.lang.String message)
Checks to see if a postponement has been specified for this message |
void |
initialiseMessageHandler(boolean DisplayDate)
This should be called to initialise the message handler after the configuration of the class 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 |
reportAlarm(java.lang.String Message,
int Blocktime)
This method will used for reporting a ALARM message into the syslog. |
void |
reportDebug(java.lang.String Message)
This method will used for reporting a debug message into the syslog if DebugMode has been enabled. |
void |
reportDebug(java.lang.String Message,
int Blocktime)
This method will used for reporting a debug message into the syslog if DebugMode has been enabled. |
void |
reportEngineering(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 |
reportError(java.lang.String Message,
int Blocktime)
This method will used for reporting a ERROR message into the syslog. |
void |
reportInfo(java.lang.String Message)
This method will used for reporting an INFO message into the syslog. |
void |
reportInfo(java.lang.String Message,
int Blocktime)
This method will used for reporting a INFO message into the syslog. |
void |
run()
Every second we check for expiry of message postponements and remove them when expired. |
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. |
void |
setEngineeringMode(boolean EnableEngineering)
Enable or suppress the output of engineering into the syslog. |
Methods inherited from class java.util.TimerTask |
---|
cancel, scheduledExecutionTime |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
private java.util.Timer checkExpireMessageBlocksTimer
private java.util.HashMap<Severity,java.util.HashMap<java.lang.Integer,java.lang.Long>> MessageExpiryTimes
private boolean DebugMode
private boolean EngineeringMode
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 run()
run
in interface java.lang.Runnable
run
in class java.util.TimerTask
public void initialiseMessageHandler(boolean DisplayDate)
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); *
DisplayDate
- True if all messages included into the
syslog will be prefixed with the current date and timeprivate void addMessageBlock(Severity severity, java.lang.String message, int delayInSecs)
severity
- The severity of the messagemessage
- The message to be blockeddelayInSecs
- The number of seconds the message should be blocked forprivate boolean checkForMessageBlock(Severity severity, java.lang.String message)
severity
- The severity of the messagemessage
- The text of the message
public void reportDebug(java.lang.String Message)
Message
- The string representation of the message to be put
into the logpublic void reportError(java.lang.String Message, int Blocktime)
Message
- The string representation of the message to be put
into the logBlocktime
- The time to block subsequent identical messages to this from being entered into the syslog in secondspublic void reportInfo(java.lang.String Message, int Blocktime)
Message
- The string representation of the message to be put
into the logBlocktime
- The time to block subsequent identical messages to this from being entered into the syslog in secondspublic void reportAlarm(java.lang.String Message, int Blocktime)
Message
- The string representation of the message to be put
into the logBlocktime
- The time to block subsequent identical messages to this from being entered into the syslog in secondspublic void reportDebug(java.lang.String Message, int Blocktime)
Message
- The string representation of the message to be put
into the logBlocktime
- The time to block subsequent identical messages to this from being entered into the syslog in secondspublic void reportEngineering(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 outputpublic void setEngineeringMode(boolean EnableEngineering)
EnableEngineering
- - Set to true in order to indicate that engineering
should be output
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |