org.safs.logging
Class AbstractLogFacility

java.lang.Object
  extended by org.safs.logging.AbstractLogFacility
Direct Known Subclasses:
SLSLogFacility

public abstract class AbstractLogFacility
extends java.lang.Object

This class is the abstract representation of log facility -- a named set of multiple logs of different type. The intention is to provide a way for writing to all of them with a single call.

Each log in a log facility is of different type and is enabled by setting its corresponding bit of the log mode identifier passed to the constructor of log facility class. Use the bitwise-OR operator and the LOGMODE constants to enable multiple logs:

long mode = AbstractLogFacility.LOGMODE_TOOL | AbstractLogFacility.LOGMODE_SAFS_TEXT;

Log message consists of the main message and an optional descriptive message, and it is of a specific message type (available message types are defined by constants of this class). Each message type is mapped to a log level. The log level of the log facility determines what messages are actually written to the logs based on the level that thier type maps to. Available levels are defined by the LOGLEVEL constants.

The logMessage and close methods of this class are abstract. Both SAFS and SAFS-enabled tools are expected to extend this class to provide the concrete implmentation of their logging functionalities. For example, SLSLogFacility extends this class and implements standard SAFS logging using STAF. A tool library should implement these methods to provide tool-specific logging, in addition to making calls to standard SAFS logging.


Field Summary
static int CUSTOM_MESSAGE
           
static int DEBUG_MESSAGE
           
protected static java.lang.String DEFAULT_FAC_NAME
          Default log facility name
protected static java.lang.String DEFAULT_SAFS_TEXT_FILE
          Default file name for standard STAF text log
protected static java.lang.String DEFAULT_SAFS_TEXT_NAME
          Default name for standard STAF text log
protected static java.lang.String DEFAULT_SAFS_XML_FILE
          Default file name for standard STAF xml log
protected static java.lang.String DEFAULT_SAFS_XML_NAME
          Default name for standard STAF xml log
protected static java.lang.String DEFAULT_XML_LOG_FOOTER
           
protected static java.lang.String DEFAULT_XML_LOG_HEADER
           
static int END_COUNTER
           
static int END_CYCLE
           
static int END_DATATABLE
           
static int END_PROCEDURE
           
static int END_REQUIREMENT
           
static int END_SUITE
           
static int END_TESTCASE
           
protected  java.lang.String facName
           
static int FAILED_MESSAGE
           
static int FAILED_OK_MESSAGE
           
static int GENERIC_MESSAGE
           
protected  java.lang.String linkedFac
           
protected  int logLevel
           
static int LOGLEVEL_DEBUG
          "3", All messages will be logged.
static int LOGLEVEL_ERROR
          "0", Only failed messages will be logged.
static int LOGLEVEL_INFO
          "2", All except debug messages will be logged.
static int LOGLEVEL_WARN
          "1", Only failed or warning messages will logged.
protected  long logMode
           
static long LOGMODE_CONSOLE
          "8", Bit flag constant for enabling tool's console log.
static long LOGMODE_DISABLED
          "0", Disable all logs.
static long LOGMODE_MAX
          "127", Enable all logs.
static long LOGMODE_SAFS_TEXT
          "32", Bit flag constant for enabling standard SAFS text file log.
static long LOGMODE_SAFS_XML
          "64", Bit flag constant for enabling standard SAFS xml file log.
static long LOGMODE_TOOL
          "1", Bit flag constant for enabling tool specific log.
static int PASSED_MESSAGE
           
static int RESUME_STATUS_COUNTS
           
static int SKIPPED_TEST_MESSAGE
           
static int START_COUNTER
           
static int START_CYCLE
           
static int START_DATATABLE
           
static int START_LOGGING
           
static int START_PROCEDURE
           
static int START_REQUIREMENT
           
static int START_SUITE
           
static int START_TESTCASE
           
static int STATUS_REPORT_END
           
static int STATUS_REPORT_GENERAL_FAILURES
           
static int STATUS_REPORT_GENERAL_WARNINGS
           
static int STATUS_REPORT_IO_FAILURES
           
static int STATUS_REPORT_RECORDS
           
static int STATUS_REPORT_SKIPPED
           
static int STATUS_REPORT_START
           
static int STATUS_REPORT_TEST_FAILURES
           
static int STATUS_REPORT_TEST_PASSES
           
static int STATUS_REPORT_TEST_WARNINGS
           
static int STATUS_REPORT_TESTS
           
static int STOP_LOGGING
           
static int SUSPEND_STATUS_COUNTS
           
protected  boolean suspended
           
static int WARNING_MESSAGE
           
static int WARNING_OK_MESSAGE
           
 
Constructor Summary
AbstractLogFacility(java.lang.String name, long mode, int level, java.lang.String linked)
          Creates a new AbstractLogFacility.
 
Method Summary
abstract  void close()
          Closes all logs of this log facility.
 java.lang.String getFacName()
          Returns the name of this log facility.
 java.lang.String getLinkedFacName()
          Returns the name of the log facility linked to this one.
 int getLogLevel()
          Returns the log level of this log facility.
 long getLogMode()
          Returns the log mode of this log facility.
 boolean isModeEnabled(long mode)
          Tests if the specified log mode is enabled.
 boolean isSuspended()
          Tests if this log facility is currently suspended.
abstract  void logMessage(java.lang.String msg, java.lang.String desc, int msgType)
          Logs a message to all the enabled logs.
 void resume()
          Resumes logging to this log facility.
 void setLogLevel(int level)
          Sets the log level of this log facility.
 void setLogMode(long mode)
          Sets the log mode of this log facility.
 void suspend()
          Suspends all logging this log facility.
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

START_PROCEDURE

public static final int START_PROCEDURE
See Also:
Constant Field Values

END_PROCEDURE

public static final int END_PROCEDURE
See Also:
Constant Field Values

START_DATATABLE

public static final int START_DATATABLE
See Also:
Constant Field Values

START_TESTCASE

public static final int START_TESTCASE
See Also:
Constant Field Values

START_SUITE

public static final int START_SUITE
See Also:
Constant Field Values

END_SUITE

public static final int END_SUITE
See Also:
Constant Field Values

END_TESTCASE

public static final int END_TESTCASE
See Also:
Constant Field Values

START_CYCLE

public static final int START_CYCLE
See Also:
Constant Field Values

END_CYCLE

public static final int END_CYCLE
See Also:
Constant Field Values

START_COUNTER

public static final int START_COUNTER
See Also:
Constant Field Values

END_COUNTER

public static final int END_COUNTER
See Also:
Constant Field Values

SUSPEND_STATUS_COUNTS

public static final int SUSPEND_STATUS_COUNTS
See Also:
Constant Field Values

RESUME_STATUS_COUNTS

public static final int RESUME_STATUS_COUNTS
See Also:
Constant Field Values

START_LOGGING

public static final int START_LOGGING
See Also:
Constant Field Values

STOP_LOGGING

public static final int STOP_LOGGING
See Also:
Constant Field Values

STATUS_REPORT_START

public static final int STATUS_REPORT_START
See Also:
Constant Field Values

STATUS_REPORT_RECORDS

public static final int STATUS_REPORT_RECORDS
See Also:
Constant Field Values

STATUS_REPORT_SKIPPED

public static final int STATUS_REPORT_SKIPPED
See Also:
Constant Field Values

STATUS_REPORT_TESTS

public static final int STATUS_REPORT_TESTS
See Also:
Constant Field Values

STATUS_REPORT_TEST_PASSES

public static final int STATUS_REPORT_TEST_PASSES
See Also:
Constant Field Values

STATUS_REPORT_TEST_WARNINGS

public static final int STATUS_REPORT_TEST_WARNINGS
See Also:
Constant Field Values

STATUS_REPORT_TEST_FAILURES

public static final int STATUS_REPORT_TEST_FAILURES
See Also:
Constant Field Values

STATUS_REPORT_GENERAL_WARNINGS

public static final int STATUS_REPORT_GENERAL_WARNINGS
See Also:
Constant Field Values

STATUS_REPORT_GENERAL_FAILURES

public static final int STATUS_REPORT_GENERAL_FAILURES
See Also:
Constant Field Values

STATUS_REPORT_IO_FAILURES

public static final int STATUS_REPORT_IO_FAILURES
See Also:
Constant Field Values

STATUS_REPORT_END

public static final int STATUS_REPORT_END
See Also:
Constant Field Values

START_REQUIREMENT

public static final int START_REQUIREMENT
See Also:
Constant Field Values

END_REQUIREMENT

public static final int END_REQUIREMENT
See Also:
Constant Field Values

SKIPPED_TEST_MESSAGE

public static final int SKIPPED_TEST_MESSAGE
See Also:
Constant Field Values

END_DATATABLE

public static final int END_DATATABLE
See Also:
Constant Field Values

DEBUG_MESSAGE

public static final int DEBUG_MESSAGE
See Also:
Constant Field Values

GENERIC_MESSAGE

public static final int GENERIC_MESSAGE
See Also:
Constant Field Values

FAILED_MESSAGE

public static final int FAILED_MESSAGE
See Also:
Constant Field Values

FAILED_OK_MESSAGE

public static final int FAILED_OK_MESSAGE
See Also:
Constant Field Values

PASSED_MESSAGE

public static final int PASSED_MESSAGE
See Also:
Constant Field Values

WARNING_MESSAGE

public static final int WARNING_MESSAGE
See Also:
Constant Field Values

WARNING_OK_MESSAGE

public static final int WARNING_OK_MESSAGE
See Also:
Constant Field Values

CUSTOM_MESSAGE

public static final int CUSTOM_MESSAGE
See Also:
Constant Field Values

LOGLEVEL_ERROR

public static final int LOGLEVEL_ERROR
"0", Only failed messages will be logged.

See Also:
Constant Field Values

LOGLEVEL_WARN

public static final int LOGLEVEL_WARN
"1", Only failed or warning messages will logged.

See Also:
Constant Field Values

LOGLEVEL_INFO

public static final int LOGLEVEL_INFO
"2", All except debug messages will be logged.

See Also:
Constant Field Values

LOGLEVEL_DEBUG

public static final int LOGLEVEL_DEBUG
"3", All messages will be logged.

See Also:
Constant Field Values

LOGMODE_DISABLED

public static final long LOGMODE_DISABLED
"0", Disable all logs. Not to be used as LogItem type.

See Also:
Constant Field Values

LOGMODE_TOOL

public static final long LOGMODE_TOOL
"1", Bit flag constant for enabling tool specific log. Also identifies a LogItem as a tool-specific log.

See Also:
Constant Field Values

LOGMODE_CONSOLE

public static final long LOGMODE_CONSOLE
"8", Bit flag constant for enabling tool's console log. Also identifies a LogItem as a tool-specific console log.

See Also:
Constant Field Values

LOGMODE_SAFS_TEXT

public static final long LOGMODE_SAFS_TEXT
"32", Bit flag constant for enabling standard SAFS text file log. Also identifies a LogItem as standard SAFS text file log.

See Also:
Constant Field Values

LOGMODE_SAFS_XML

public static final long LOGMODE_SAFS_XML
"64", Bit flag constant for enabling standard SAFS xml file log. Also identifies a LogItem as standard SAFS xml file log.

See Also:
Constant Field Values

LOGMODE_MAX

public static final long LOGMODE_MAX
"127", Enable all logs. Not to be used as LogItem type.

See Also:
Constant Field Values

DEFAULT_FAC_NAME

protected static final java.lang.String DEFAULT_FAC_NAME
Default log facility name

See Also:
Constant Field Values

DEFAULT_SAFS_TEXT_NAME

protected static final java.lang.String DEFAULT_SAFS_TEXT_NAME
Default name for standard STAF text log

See Also:
Constant Field Values

DEFAULT_SAFS_TEXT_FILE

protected static final java.lang.String DEFAULT_SAFS_TEXT_FILE
Default file name for standard STAF text log

See Also:
Constant Field Values

DEFAULT_SAFS_XML_NAME

protected static final java.lang.String DEFAULT_SAFS_XML_NAME
Default name for standard STAF xml log

See Also:
Constant Field Values

DEFAULT_SAFS_XML_FILE

protected static final java.lang.String DEFAULT_SAFS_XML_FILE
Default file name for standard STAF xml log

See Also:
Constant Field Values

DEFAULT_XML_LOG_HEADER

protected static final java.lang.String DEFAULT_XML_LOG_HEADER
See Also:
Constant Field Values

DEFAULT_XML_LOG_FOOTER

protected static final java.lang.String DEFAULT_XML_LOG_FOOTER
See Also:
Constant Field Values

facName

protected java.lang.String facName

logMode

protected long logMode

logLevel

protected int logLevel

linkedFac

protected java.lang.String linkedFac

suspended

protected boolean suspended
Constructor Detail

AbstractLogFacility

public AbstractLogFacility(java.lang.String name,
                           long mode,
                           int level,
                           java.lang.String linked)
Creates a new AbstractLogFacility.

Parameters:
name - the name of this log facility.
mode - the log mode.
level - the log level.
linked - the name of another log facility linked to this one.
Method Detail

getFacName

public java.lang.String getFacName()
Returns the name of this log facility.

Returns:
the name of this log facility.

getLogMode

public long getLogMode()
Returns the log mode of this log facility.

Returns:
the bitwise-OR of one of more LOGMODE constants.

setLogMode

public void setLogMode(long mode)
Sets the log mode of this log facility.

Parameters:
mode - the new log mode. Bitwise-OR of one or more LOGMODE constants.

getLogLevel

public int getLogLevel()
Returns the log level of this log facility.

Returns:
one of the LOGLEVEL constants.

setLogLevel

public void setLogLevel(int level)
Sets the log level of this log facility.

Parameters:
level - the new log level. Must be one of the LOGLEVEL constants.

getLinkedFacName

public java.lang.String getLinkedFacName()
Returns the name of the log facility linked to this one.

Returns:
the name of the linked log facility.

isModeEnabled

public boolean isModeEnabled(long mode)
Tests if the specified log mode is enabled.

Parameters:
mode - the mode to test. Must be one of the LOGMODE constants.
Returns:
true if mode is enabled; false if not.

suspend

public void suspend()
Suspends all logging this log facility.

Incoming log messages are discarded until resumed.


resume

public void resume()
Resumes logging to this log facility.


isSuspended

public boolean isSuspended()
Tests if this log facility is currently suspended.

Returns:
true if suspended; false if not.

logMessage

public abstract void logMessage(java.lang.String msg,
                                java.lang.String desc,
                                int msgType)
Logs a message to all the enabled logs.

Parameters:
msg - the message to log.
desc - additional description to log.
msgType - the int identifier of the type of message being logged.

close

public abstract void close()
                    throws LogException
Closes all logs of this log facility.

Throws:
LogException - if this log facility failed to close for any reason.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object
Returns:
the name of this log facility.