public abstract class SLSLogFacility extends AbstractLogFacility
SLSLogFacility
is the abstract log facility solely used by
SAFSLoggingService
.
In addition to common attributes defined in its super class,
AbstractLogFacility
, this log facility contains a STAF
handle, a default log directory, and a pair of
and AbstractSTAFTextLogItem
for standard SAFS text/xml logs. The STAF handle is used to interact with
STAF. The default log directory corresponds to the AbstractSTAFXmlLogItem
DIR
setting
of the SAFS logging service.
Internally, this class performs logging functions asynchronously to maximize
its performance. The main thread accepts log message requests (i.e. calls to
the logMessage
method) and puts them on a request queue.
A worker thread is expected to check the queue for any request and performs
actual logging actions.
Depending on the mode (local or remote) of the logging service, the actual
logging and closing implementations would be different. Therefore the
closeNow()
method and the SLSLogFacility.WorkerThread
inner class, which does
the actual logging, are abstract and expected to be implemented by
subclasses.
Modifier and Type | Class and Description |
---|---|
protected class |
SLSLogFacility.RequestQueue
This class implements the (FIFO) request queue used internally by this
log facility.
|
protected class |
SLSLogFacility.WorkerRequest
This class is the queued request for the worker thread of this log
facility.
|
protected class |
SLSLogFacility.WorkerThread
This is the worker thread that fulfills the log message request received
by this log facility.
|
Modifier and Type | Field and Description |
---|---|
protected LogItemDictionary |
allLogs |
protected ServiceDebugLog |
debugLog |
protected java.lang.String |
defaultDir |
protected HandleInterface |
handle |
protected SLSLogFacility.RequestQueue |
rQueue |
static java.lang.String |
STAF_TEXT_LOG_ITEM_V2 |
static java.lang.String |
STAF_TEXT_LOG_ITEM_V3 |
static java.lang.String |
STAF_XML_LOG_ITEM_V2 |
static java.lang.String |
STAF_XML_LOG_ITEM_V3 |
protected SLSLogFacility.WorkerThread |
workerThread |
CUSTOM_MESSAGE, DEBUG_MESSAGE, DEFAULT_FAC_NAME, DEFAULT_SAFS_TEXT_FILE, DEFAULT_SAFS_TEXT_NAME, DEFAULT_SAFS_XML_FILE, DEFAULT_SAFS_XML_NAME, DEFAULT_XML_LOG_FOOTER, DEFAULT_XML_LOG_HEADER, END_COUNTER, END_CYCLE, END_DATATABLE, END_PROCEDURE, END_REQUIREMENT, END_SUITE, END_TESTCASE, facName, FAILED_MESSAGE, FAILED_OK_MESSAGE, GENERIC_MESSAGE, linkedFac, logLevel, LOGLEVEL_DEBUG, LOGLEVEL_ERROR, LOGLEVEL_INFO, LOGLEVEL_WARN, logMode, LOGMODE_CONSOLE, LOGMODE_DISABLED, LOGMODE_MAX, LOGMODE_SAFS_TEXT, LOGMODE_SAFS_XML, LOGMODE_TOOL, PASSED_MESSAGE, RESUME_STATUS_COUNTS, SKIPPED_TEST_MESSAGE, START_COUNTER, START_CYCLE, START_DATATABLE, START_LOGGING, START_PROCEDURE, START_REQUIREMENT, START_SUITE, START_TESTCASE, STATUS_REPORT_END, STATUS_REPORT_GENERAL, STATUS_REPORT_GENERAL_FAILURES, STATUS_REPORT_GENERAL_PASSES, STATUS_REPORT_GENERAL_WARNINGS, STATUS_REPORT_IO_FAILURES, STATUS_REPORT_RECORDS, STATUS_REPORT_SKIPPED, STATUS_REPORT_START, STATUS_REPORT_TEST_FAILURES, STATUS_REPORT_TEST_PASSES, STATUS_REPORT_TEST_WARNINGS, STATUS_REPORT_TESTS, STOP_LOGGING, SUSPEND_STATUS_COUNTS, suspended, WARNING_MESSAGE, WARNING_OK_MESSAGE
Constructor and Description |
---|
SLSLogFacility(java.lang.String name,
long mode,
int level,
java.lang.String linked,
HandleInterface h,
java.lang.String dir,
LogItemDictionary logs,
ServiceDebugLog debugLog)
Creates a
SLSLogFacility . |
Modifier and Type | Method and Description |
---|---|
void |
close()
Closes this log facility.
|
protected abstract void |
closeNow()
Closes this log facility immediately.
|
java.lang.String |
getConsoleLogStateString()
Returns the string representation of the current state of the console
log.
|
java.lang.String |
getSAFSTextLogStateString()
Returns the string representation of the current state of
STAFTextLogItem . |
java.lang.String |
getSAFSXmlLogStateString()
Returns the string representation of the current state of
STAFXmlLogItem . |
java.lang.String |
getStatesString()
Returns the string representation of the states of this log facility.
|
java.lang.String |
getToolLogStateString()
Returns the string representation of the current state of the tool log.
|
void |
logMessage(java.lang.String msg,
java.lang.String desc,
int msgType)
Logs a message.
|
protected void |
setDebugLog(ServiceDebugLog debugLog) |
void |
setDefaultDir(java.lang.String dir)
Sets the default log directory of this log facility.
|
void |
setHandle(HandleInterface h)
Sets the STAF handle for 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 |
setSAFSXmlLogCapXML(boolean capbool)
Set the capXML setting for the XML log.
|
getFacName, getLinkedFacName, getLogLevel, getLogMode, isModeEnabled, isSuspended, resume, suspend, toString
public static java.lang.String STAF_TEXT_LOG_ITEM_V2
public static java.lang.String STAF_XML_LOG_ITEM_V2
public static java.lang.String STAF_TEXT_LOG_ITEM_V3
public static java.lang.String STAF_XML_LOG_ITEM_V3
protected HandleInterface handle
protected java.lang.String defaultDir
protected LogItemDictionary allLogs
protected SLSLogFacility.RequestQueue rQueue
protected SLSLogFacility.WorkerThread workerThread
protected ServiceDebugLog debugLog
public SLSLogFacility(java.lang.String name, long mode, int level, java.lang.String linked, HandleInterface h, java.lang.String dir, LogItemDictionary logs, ServiceDebugLog debugLog)
SLSLogFacility
.
name
- the name of this log facility.mode
- the log mode.level
- the log level for this log facility.linked
- the name of another log facility linked to this one.h
- a STAF handle to interact with STAF.dir
- the default log directory.logs
- the spec of a STAFTextLogItem
and
STAFXmlLogItem
. If a log item is omitted,
default settings (file name, parent directory etc) will
be used.debugLog
- is used to write debug message to a filepublic void setLogMode(long mode)
This method also sets the enabled state of each LogItem
accordingly.
setLogMode
in class AbstractLogFacility
mode
- the new log mode. Bitwise-OR of one or more
LOGMODE
constants.public void setLogLevel(int level)
This method also sets the log level of each LogItem
.
setLogLevel
in class AbstractLogFacility
level
- the new log level. Must be one of the LOGLEVEL
constants.public void setDefaultDir(java.lang.String dir)
Parent directory of each FileLogItem
is set to the new value
as well.
dir
- the new default directory.public void setHandle(HandleInterface h)
STAF handle of each STAFFileLogItem
is set to the new value
as well.
h
- the new STAF handle.public java.lang.String getSAFSTextLogStateString()
STAFTextLogItem
.
public java.lang.String getSAFSXmlLogStateString()
STAFXmlLogItem
.
public void setSAFSXmlLogCapXML(boolean capbool)
capbool
- true to force XML capping on closure.public java.lang.String getToolLogStateString()
public java.lang.String getConsoleLogStateString()
public java.lang.String getStatesString()
This string is included in the result buffer of every LOGMESSAGE request to let the user of the logging service, such as a SAFS-aware testing tool, know the current state of this log facility, so that it could perform tool-specific logging actions accordingly.
SLSLogFacilityStates
to parse the string.public void logMessage(java.lang.String msg, java.lang.String desc, int msgType)
If this log facility is not suspended, and the message type is not filtered out by the current log level, this method creates a log request and puts it on the request queue for the worker thread to process.
logMessage
in class AbstractLogFacility
msg
- the message to log.desc
- additional description to log.msgType
- the int identifier of the type of message being logged.public void close() throws STAFLogException
This method waits for the request queue to clear before actually shuts down the log facility. It also signals the worker thread to exit (and wait until it acutally dies) before return.
close
in class AbstractLogFacility
STAFLogException
- if this method failed for any reason.protected abstract void closeNow() throws STAFLogException
This method is called by the close
method to actually shut
down this log facility.
STAFLogException
- if failed to close this log facility for any reason.protected void setDebugLog(ServiceDebugLog debugLog)
Copyright © SAS Institute. All Rights Reserved.