public abstract class AbstractLogFacility
extends java.lang.Object
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
and
logMessage
methods of this class are abstract. Both
SAFS and SAFS-enabled tools are expected to extend this class to provide
the concrete implementation of their logging functionalities. For example,
close
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.SLSLogFacility
Modifier and Type | Field and Description |
---|---|
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_STEP |
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 |
ORDERABLE_LOGGING |
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_STEP |
static int |
START_SUITE |
static int |
START_TESTCASE |
static int |
STATUS_REPORT_END |
static int |
STATUS_REPORT_GENERAL |
static int |
STATUS_REPORT_GENERAL_FAILURES |
static int |
STATUS_REPORT_GENERAL_PASSES |
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_TESTCASE_COMMENT |
static int |
STATUS_REPORT_TESTCASE_STATUS |
static int |
STATUS_REPORT_TESTCASE_TRACKING_SYSTEM |
static int |
STATUS_REPORT_TESTS |
static int |
STOP_LOGGING |
static int |
SUSPEND_STATUS_COUNTS |
protected boolean |
suspended |
static int |
TESTLEVEL_ERRORED |
static int |
TESTLEVEL_FAILED |
static int |
TESTLEVEL_SKIPPED |
static int |
WARNING_MESSAGE |
static int |
WARNING_OK_MESSAGE |
Constructor and Description |
---|
AbstractLogFacility(java.lang.String name,
long mode,
int level,
java.lang.String linked)
Creates a new
AbstractLogFacility . |
Modifier and Type | Method and Description |
---|---|
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() |
public static final int START_PROCEDURE
public static final int END_PROCEDURE
public static final int START_DATATABLE
public static final int START_TESTCASE
public static final int START_SUITE
public static final int END_SUITE
public static final int END_TESTCASE
public static final int START_CYCLE
public static final int END_CYCLE
public static final int START_COUNTER
public static final int END_COUNTER
public static final int SUSPEND_STATUS_COUNTS
public static final int RESUME_STATUS_COUNTS
public static final int START_LOGGING
public static final int STOP_LOGGING
public static final int ORDERABLE_LOGGING
public static final int TESTLEVEL_FAILED
public static final int TESTLEVEL_ERRORED
public static final int TESTLEVEL_SKIPPED
public static final int START_STEP
public static final int END_STEP
public static final int STATUS_REPORT_START
public static final int STATUS_REPORT_RECORDS
public static final int STATUS_REPORT_SKIPPED
public static final int STATUS_REPORT_TESTS
public static final int STATUS_REPORT_TEST_PASSES
public static final int STATUS_REPORT_TEST_WARNINGS
public static final int STATUS_REPORT_TEST_FAILURES
public static final int STATUS_REPORT_GENERAL_WARNINGS
public static final int STATUS_REPORT_GENERAL_FAILURES
public static final int STATUS_REPORT_IO_FAILURES
public static final int STATUS_REPORT_GENERAL
public static final int STATUS_REPORT_GENERAL_PASSES
public static final int STATUS_REPORT_END
public static final int STATUS_REPORT_TESTCASE_TRACKING_SYSTEM
public static final int STATUS_REPORT_TESTCASE_STATUS
public static final int STATUS_REPORT_TESTCASE_COMMENT
public static final int START_REQUIREMENT
public static final int END_REQUIREMENT
public static final int SKIPPED_TEST_MESSAGE
public static final int END_DATATABLE
public static final int DEBUG_MESSAGE
public static final int GENERIC_MESSAGE
public static final int FAILED_MESSAGE
public static final int FAILED_OK_MESSAGE
public static final int PASSED_MESSAGE
public static final int WARNING_MESSAGE
public static final int WARNING_OK_MESSAGE
public static final int CUSTOM_MESSAGE
public static final int LOGLEVEL_ERROR
public static final int LOGLEVEL_WARN
public static final int LOGLEVEL_INFO
public static final int LOGLEVEL_DEBUG
public static final long LOGMODE_DISABLED
LogItem
type.public static final long LOGMODE_TOOL
LogItem
as a tool-specific log.public static final long LOGMODE_CONSOLE
LogItem
as a tool-specific console log.public static final long LOGMODE_SAFS_TEXT
LogItem
as standard SAFS text file log.public static final long LOGMODE_SAFS_XML
LogItem
as standard SAFS xml file log.public static final long LOGMODE_MAX
LogItem
type.protected static final java.lang.String DEFAULT_FAC_NAME
protected static final java.lang.String DEFAULT_SAFS_TEXT_NAME
protected static final java.lang.String DEFAULT_SAFS_TEXT_FILE
protected static final java.lang.String DEFAULT_SAFS_XML_NAME
protected static final java.lang.String DEFAULT_SAFS_XML_FILE
protected static final java.lang.String DEFAULT_XML_LOG_HEADER
protected static final java.lang.String DEFAULT_XML_LOG_FOOTER
protected java.lang.String facName
protected long logMode
protected int logLevel
protected java.lang.String linkedFac
protected boolean suspended
public AbstractLogFacility(java.lang.String name, long mode, int level, java.lang.String linked)
AbstractLogFacility
.
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.public java.lang.String getFacName()
public long getLogMode()
LOGMODE
constants.public void setLogMode(long mode)
mode
- the new log mode. Bitwise-OR of one or more
LOGMODE
constants.public int getLogLevel()
LOGLEVEL
constants.public void setLogLevel(int level)
level
- the new log level. Must be one of the LOGLEVEL
constants.public java.lang.String getLinkedFacName()
public boolean isModeEnabled(long mode)
mode
- the mode to test. Must be one of the LOGMODE
constants.true
if mode
is enabled;
false
if not.public void suspend()
Incoming log messages are discarded until resumed.
public void resume()
public boolean isSuspended()
true
if suspended; false
if not.public abstract void logMessage(java.lang.String msg, java.lang.String desc, int msgType)
msg
- the message to log.desc
- additional description to log.msgType
- the int identifier of the type of message being logged.public abstract void close() throws LogException
LogException
- if this log facility failed to close for any reason.public java.lang.String toString()
toString
in class java.lang.Object
Copyright © SAS Institute. All Rights Reserved.