public abstract class AbstractSAFSLoggingService
extends java.lang.Object
AbstractSAFSLoggingService
is an external STAF service that handles
standard SAFS logging.
This class is defined as an abstract class, for different version of STAF,
you may extends this class and implements the staf-version-related interface
(STAFServiceInterfaceLevel30 or STAFServiceInterfaceLevel3).
We have implemented the class for version 2 and 3: SAFSLoggingService and SAFSLoggingService3
This service supports multiple processes (SAFS-aware testing tools) running
in support of the same test at the same time to write to the same log
facility (see
). It
provides all standard SAFS logging functions, including creating new log
facilities, interrogating and manipulating settings of existing log
facilities, logging messages etc. This service also keeps track of all log
facilities that it created. All tools should perform standard SAFS logging
via this service so that their logging actions can be coordinated.
AbstractLogFacility
Internally this service uses STAF LOG service to store messages for running logs until they are closed, when the content of the STAF log is exported to the destination. Upon initializing, this service will load a unique instance of STAF LOG service to use for the temporary STAF logs (The name of this STAF LOG service instance is "<ServiceName>Log", where <ServiceName> is the registered name of this service).
This service can operate in two modes: local or remote, which is specified when this service is registered with STAF (statically via STAF.cfg file or dynamically using the SERVICE service). In local mode, logs are generated on the local machine. In remote mode, logs are generated on a remote machine. In this case, the remote machine must be running this service in local mode. Settings such as the default log directory are all with respect to the remote machine. The local service simply serves as a proxy to the remote service. From a user's perspective, however, there is absolutely no difference at all in how to submit requests to this service.
This service can also invoke custom logging functions, which must be implemented as a STAF service. A custom logging service is required to expose certain commands that this service will call. Custom logging can only be enabled in local mode.
Registration of this service takes the following format:
SERVICE <ServiceName> LIBRARY JSTAF EXECUTE <ServiceJarFile> PARMS
[DIR <LogDir>] [REMOTE <RemoteMachine> [NAME <RemoteServiceName>]]
[CUSTOMLOGGING <CustomLoggingService>]
Example:
SERVICE SAFSLogs LIBRARY JSTAF EXECUTE c:\staf\services\SAFSLogs.jar PARMS
DIR c:\safslogs
SERVICE SAFSLogs LIBRARY JSTAF EXECUTE c:\staf\services\SAFSLogs.jar PARMS
DIR c:\safslogs CUSTOMLOGGING SAFSCustomLogs
SERVICE SAFSLogs LIBRARY JSTAF EXECUTE c:\staf\services\SAFSLogs.jar PARMS
REMOTE LogServer
This service provides the following commands:
HANDLEID INIT <facname> [TEXTLOG [<altname>]] [XMLLOG [<altname>]] [TOOLLOG] [CONSOLELOG] [ALL] [LINKEDFAC <name>] [OVERWRITE] [CAPXML] [TRUNCATE [<numchars | ON | OFF ]] QUERY <facname> [TEXTLOG | XMLLOG | TOOLLOG | CONSOLELOG | ALL] LIST [SETTINGS] SUSPENDLOG <facname> | ALL RESUMELOG <facname> | ALL LOGLEVEL <facname> [DEBUG | INFO | WARN | ERROR] LOGMESSAGE <facname> MESSAGE <msg> [DESCRIPTION <desc>] [MSGTYPE <msgType>] TRUNCATE [<numchars | ON | OFF ] CLOSE <facname> | ALL [CAPXML] HELP [MSGTYPE] VERSION
AbstractLogFacility
,
SLSLogFacility
,
SAFSCustomLoggingService
,
SAFSCustomLoggingService3
,
"SAFSLogs Service User's Guide",
SAFSLoggingService
,
SAFSLoggingService3
Modifier and Type | Field and Description |
---|---|
protected com.ibm.staf.service.STAFCommandParser |
closeParser |
protected java.lang.String |
customService |
protected ServiceDebugLog |
debugLog |
protected java.lang.String |
defaultDir |
protected static HandleInterface |
handle |
static java.lang.String |
HELP_MSGTYPE_STR |
static java.lang.String |
HELP_STR |
protected com.ibm.staf.service.STAFCommandParser |
helpParser |
protected com.ibm.staf.service.STAFCommandParser |
initParser |
protected com.ibm.staf.service.STAFCommandParser |
listParser |
protected java.util.Hashtable |
logfacs
Stores all open log facilities created by this service.
|
protected com.ibm.staf.service.STAFCommandParser |
logLevelParser |
protected com.ibm.staf.service.STAFCommandParser |
logMessageParser |
protected java.lang.String |
mode |
protected java.lang.String |
procName |
protected com.ibm.staf.service.STAFCommandParser |
queryParser |
protected java.lang.String |
remoteMachine |
protected java.lang.String |
remoteService |
protected com.ibm.staf.service.STAFCommandParser |
resumeLogParser |
protected java.lang.String |
servicename |
static java.lang.String |
SLS_SERVICE_MODE_LOCAL |
static java.lang.String |
SLS_SERVICE_MODE_REMOTE |
static java.lang.String |
SLS_SERVICE_OPTION_CUSTOMLOGGING |
static java.lang.String |
SLS_SERVICE_OPTION_DIR |
static java.lang.String |
SLS_SERVICE_OPTION_NAME |
static java.lang.String |
SLS_SERVICE_OPTION_REMOTE |
static java.lang.String |
SLS_SERVICE_PARM_ALL |
static java.lang.String |
SLS_SERVICE_PARM_CAPXML |
static java.lang.String |
SLS_SERVICE_PARM_CONSOLELOG |
static java.lang.String |
SLS_SERVICE_PARM_DEBUG |
static java.lang.String |
SLS_SERVICE_PARM_DESCRIPTION |
static java.lang.String |
SLS_SERVICE_PARM_ERROR |
static java.lang.String |
SLS_SERVICE_PARM_INFO |
static java.lang.String |
SLS_SERVICE_PARM_LINKEDFAC |
static java.lang.String |
SLS_SERVICE_PARM_MESSAGE |
static java.lang.String |
SLS_SERVICE_PARM_MSGTYPE |
static java.lang.String |
SLS_SERVICE_PARM_OFF |
static java.lang.String |
SLS_SERVICE_PARM_ON |
static java.lang.String |
SLS_SERVICE_PARM_OVERWRITE |
static java.lang.String |
SLS_SERVICE_PARM_SETTINGS |
static java.lang.String |
SLS_SERVICE_PARM_TEXTLOG |
static java.lang.String |
SLS_SERVICE_PARM_TOOLLOG |
static java.lang.String |
SLS_SERVICE_PARM_WARN |
static java.lang.String |
SLS_SERVICE_PARM_XMLLOG |
static java.lang.String |
SLS_SERVICE_REQUEST_CLOSE |
static java.lang.String |
SLS_SERVICE_REQUEST_HANDLEID |
static java.lang.String |
SLS_SERVICE_REQUEST_HELP |
static java.lang.String |
SLS_SERVICE_REQUEST_INIT |
static java.lang.String |
SLS_SERVICE_REQUEST_LIST |
static java.lang.String |
SLS_SERVICE_REQUEST_LOGLEVEL |
static java.lang.String |
SLS_SERVICE_REQUEST_LOGMESSAGE |
static java.lang.String |
SLS_SERVICE_REQUEST_QUERY |
static java.lang.String |
SLS_SERVICE_REQUEST_RESUMELOG |
static java.lang.String |
SLS_SERVICE_REQUEST_SUSPENDLOG |
static java.lang.String |
SLS_SERVICE_REQUEST_TRUNCATE |
static java.lang.String |
SLS_SERVICE_REQUEST_VERSION |
static java.lang.String |
SLS_SETTINGS_CUSTOM_LOGGING_PREFIX
Prefix to the custom logging service setting of this service in response
to the LIST SETTINGS command.
|
static java.lang.String |
SLS_SETTINGS_DEFAULT_DIR_PREFIX
Prefix to the default directory setting of this service in response to
the LIST SETTINGS command.
|
static java.lang.String |
SLS_SETTINGS_MODE_PREFIX
Prefix to the mode setting of this service in response to the LIST
SETTINGS command.
|
static java.lang.String |
SLS_SETTINGS_REMOTE_MACHINE_PREFIX
Prefix to the remote machine setting of this service in response to the
LIST SETTINGS command.
|
static java.lang.String |
SLS_SETTINGS_REMOTE_SERVICE_PREFIX
Prefix to the remote service setting of this service in response to the
LIST SETTINGS command.
|
static java.lang.String |
SLS_STAF_LOG_SERVICE_NAME
The name of the separate instance of STAF LOG service loaded and used
solely by this service in local mode.
|
static java.lang.String |
SLS_STATES_CONSOLELOG_PREFIX
Prefix to the consolelog state of this service in the result buffer of
every LOGMESSAGE command.
|
static java.lang.String |
SLS_STATES_LOGLEVEL_PREFIX
Prefix to the log level state of this service in the result buffer of
every LOGMESSAGE command.
|
static java.lang.String |
SLS_STATES_TOOLLOG_PREFIX
Prefix to the toollog state of this service in the result buffer of
every LOGMESSAGE command.
|
static int |
SLS_TRUNCATELENGTH_DEFAULT |
protected com.ibm.staf.service.STAFCommandParser |
suspendLogParser |
protected int |
truncateLength |
protected boolean |
truncateLines |
protected com.ibm.staf.service.STAFCommandParser |
truncateParser |
static java.lang.String |
VERSION_STR |
Constructor and Description |
---|
AbstractSAFSLoggingService() |
Modifier and Type | Method and Description |
---|---|
com.ibm.staf.STAFResult |
acceptRequest(InfoInterface.RequestInfo info)
Handles service request from STAF.
|
protected void |
createCloseParser() |
protected void |
createHelpParser() |
protected void |
createInitParser() |
protected void |
createListParser() |
protected void |
createLogLevelParser() |
protected void |
createLogMessageParser() |
protected void |
createQueryParser() |
protected void |
createResumeParser() |
protected void |
createSuspendLogParser() |
protected void |
createTruncateParser() |
protected abstract AbstractSTAFTextLogItem |
getSTAFTextLogItem(java.lang.String name,
java.lang.String directory,
java.lang.String filename) |
protected abstract AbstractSTAFXmlLogItem |
getSTAFXmlLogItem(java.lang.String name,
java.lang.String directory,
java.lang.String filename) |
protected com.ibm.staf.STAFResult |
handleClose(InfoInterface.RequestInfo info) |
protected com.ibm.staf.STAFResult |
handleHandleId(InfoInterface.RequestInfo info) |
protected com.ibm.staf.STAFResult |
handleHelp(InfoInterface.RequestInfo info) |
protected com.ibm.staf.STAFResult |
handleInit(InfoInterface.RequestInfo info) |
protected com.ibm.staf.STAFResult |
handleList(InfoInterface.RequestInfo info) |
protected com.ibm.staf.STAFResult |
handleLogLevel(InfoInterface.RequestInfo info) |
protected com.ibm.staf.STAFResult |
handleLogMessage(InfoInterface.RequestInfo info) |
protected com.ibm.staf.STAFResult |
handleQuery(InfoInterface.RequestInfo info) |
protected com.ibm.staf.STAFResult |
handleResumeLog(InfoInterface.RequestInfo info) |
protected com.ibm.staf.STAFResult |
handleSuspendLog(InfoInterface.RequestInfo info) |
protected com.ibm.staf.STAFResult |
handleTruncate(InfoInterface.RequestInfo info) |
protected com.ibm.staf.STAFResult |
handleVersion(InfoInterface.RequestInfo info) |
com.ibm.staf.STAFResult |
init(InfoInterface.InitInfo info) |
protected com.ibm.staf.STAFResult |
initSTAFLogService()
Subclasses can override to change the STAFLog service initialization, or even
bypass it entirely if not used.
|
protected int |
loadServiceInitParameters(InfoInterface.InitInfo info)
Loads the service initialization parameters.
|
protected java.lang.String |
normalizeAltname(java.lang.String altname,
java.lang.String filename)
Makes sure the
altname option value is a file. |
protected void |
registerHandle(java.lang.String handleId) |
com.ibm.staf.STAFResult |
terminate()
Handles removing this service from STAF.
|
public static java.lang.String SLS_STAF_LOG_SERVICE_NAME
public static final java.lang.String SLS_SERVICE_MODE_LOCAL
public static final java.lang.String SLS_SERVICE_MODE_REMOTE
public static final java.lang.String SLS_SERVICE_OPTION_DIR
public static final java.lang.String SLS_SERVICE_OPTION_CUSTOMLOGGING
public static final java.lang.String SLS_SERVICE_OPTION_REMOTE
public static final java.lang.String SLS_SERVICE_OPTION_NAME
public static final java.lang.String SLS_SERVICE_REQUEST_HANDLEID
public static final java.lang.String SLS_SERVICE_REQUEST_INIT
public static final java.lang.String SLS_SERVICE_REQUEST_QUERY
public static final java.lang.String SLS_SERVICE_REQUEST_LIST
public static final java.lang.String SLS_SERVICE_REQUEST_SUSPENDLOG
public static final java.lang.String SLS_SERVICE_REQUEST_RESUMELOG
public static final java.lang.String SLS_SERVICE_REQUEST_LOGLEVEL
public static final java.lang.String SLS_SERVICE_REQUEST_LOGMESSAGE
public static final java.lang.String SLS_SERVICE_REQUEST_CLOSE
public static final java.lang.String SLS_SERVICE_REQUEST_HELP
public static final java.lang.String SLS_SERVICE_REQUEST_VERSION
public static final java.lang.String SLS_SERVICE_REQUEST_TRUNCATE
public static final java.lang.String SLS_SERVICE_PARM_ON
public static final java.lang.String SLS_SERVICE_PARM_OFF
public static final java.lang.String SLS_SERVICE_PARM_ALL
public static final java.lang.String SLS_SERVICE_PARM_TEXTLOG
public static final java.lang.String SLS_SERVICE_PARM_XMLLOG
public static final java.lang.String SLS_SERVICE_PARM_TOOLLOG
public static final java.lang.String SLS_SERVICE_PARM_CONSOLELOG
public static final java.lang.String SLS_SERVICE_PARM_LINKEDFAC
public static final java.lang.String SLS_SERVICE_PARM_OVERWRITE
public static final java.lang.String SLS_SERVICE_PARM_CAPXML
public static final java.lang.String SLS_SERVICE_PARM_SETTINGS
public static final java.lang.String SLS_SERVICE_PARM_DEBUG
public static final java.lang.String SLS_SERVICE_PARM_INFO
public static final java.lang.String SLS_SERVICE_PARM_WARN
public static final java.lang.String SLS_SERVICE_PARM_ERROR
public static final java.lang.String SLS_SERVICE_PARM_MESSAGE
public static final java.lang.String SLS_SERVICE_PARM_DESCRIPTION
public static final java.lang.String SLS_SERVICE_PARM_MSGTYPE
public static final java.lang.String SLS_SETTINGS_MODE_PREFIX
public static final java.lang.String SLS_SETTINGS_REMOTE_MACHINE_PREFIX
public static final java.lang.String SLS_SETTINGS_REMOTE_SERVICE_PREFIX
public static final java.lang.String SLS_SETTINGS_DEFAULT_DIR_PREFIX
public static final java.lang.String SLS_SETTINGS_CUSTOM_LOGGING_PREFIX
public static final java.lang.String SLS_STATES_TOOLLOG_PREFIX
public static final java.lang.String SLS_STATES_CONSOLELOG_PREFIX
public static final java.lang.String SLS_STATES_LOGLEVEL_PREFIX
public static final int SLS_TRUNCATELENGTH_DEFAULT
public static final java.lang.String VERSION_STR
public static final java.lang.String HELP_STR
public static final java.lang.String HELP_MSGTYPE_STR
protected java.util.Hashtable logfacs
protected static HandleInterface handle
protected com.ibm.staf.service.STAFCommandParser initParser
protected com.ibm.staf.service.STAFCommandParser queryParser
protected com.ibm.staf.service.STAFCommandParser listParser
protected com.ibm.staf.service.STAFCommandParser suspendLogParser
protected com.ibm.staf.service.STAFCommandParser resumeLogParser
protected com.ibm.staf.service.STAFCommandParser logLevelParser
protected com.ibm.staf.service.STAFCommandParser logMessageParser
protected com.ibm.staf.service.STAFCommandParser closeParser
protected com.ibm.staf.service.STAFCommandParser helpParser
protected com.ibm.staf.service.STAFCommandParser truncateParser
protected java.lang.String procName
protected java.lang.String servicename
protected java.lang.String mode
protected java.lang.String defaultDir
protected java.lang.String remoteMachine
protected java.lang.String remoteService
protected java.lang.String customService
protected boolean truncateLines
protected int truncateLength
protected ServiceDebugLog debugLog
protected int loadServiceInitParameters(InfoInterface.InitInfo info)
info
- the InitInfo
from STAF.protected void createInitParser()
protected void createQueryParser()
protected void createListParser()
protected void createSuspendLogParser()
protected void createResumeParser()
protected void createLogLevelParser()
protected void createLogMessageParser()
protected void createCloseParser()
protected void createTruncateParser()
protected void createHelpParser()
protected com.ibm.staf.STAFResult handleHandleId(InfoInterface.RequestInfo info)
protected abstract AbstractSTAFTextLogItem getSTAFTextLogItem(java.lang.String name, java.lang.String directory, java.lang.String filename)
protected abstract AbstractSTAFXmlLogItem getSTAFXmlLogItem(java.lang.String name, java.lang.String directory, java.lang.String filename)
protected com.ibm.staf.STAFResult handleInit(InfoInterface.RequestInfo info)
protected java.lang.String normalizeAltname(java.lang.String altname, java.lang.String filename)
altname
option value is a file.
The altname
option in the INIT request can specify either a
file or a directory. Directory spec ends with a name separator, e.g. "\"
for Win32. In this case, altname + filename
is returned as
the file spec for the log file.
altname
- the altname
option value. Directory spec
ends with File.separator
.filename
- the default file name to use to build the file spec in
case altname
is a directory. Ignored if
altname
is a file.protected com.ibm.staf.STAFResult handleQuery(InfoInterface.RequestInfo info)
protected com.ibm.staf.STAFResult handleList(InfoInterface.RequestInfo info)
protected com.ibm.staf.STAFResult handleSuspendLog(InfoInterface.RequestInfo info)
protected com.ibm.staf.STAFResult handleResumeLog(InfoInterface.RequestInfo info)
protected com.ibm.staf.STAFResult handleLogLevel(InfoInterface.RequestInfo info)
protected com.ibm.staf.STAFResult handleLogMessage(InfoInterface.RequestInfo info)
protected com.ibm.staf.STAFResult handleTruncate(InfoInterface.RequestInfo info)
protected com.ibm.staf.STAFResult handleClose(InfoInterface.RequestInfo info)
protected com.ibm.staf.STAFResult handleHelp(InfoInterface.RequestInfo info)
protected com.ibm.staf.STAFResult handleVersion(InfoInterface.RequestInfo info)
protected void registerHandle(java.lang.String handleId) throws com.ibm.staf.STAFException
com.ibm.staf.STAFException
public com.ibm.staf.STAFResult init(InfoInterface.InitInfo info)
protected com.ibm.staf.STAFResult initSTAFLogService()
public com.ibm.staf.STAFResult acceptRequest(InfoInterface.RequestInfo info)
public com.ibm.staf.STAFResult terminate()
All log facilities are forced to close.
Copyright © SAS Institute. All Rights Reserved.