org.safs.staf.service.logging
Class SAFSLoggingService

java.lang.Object
  extended by org.safs.staf.service.logging.SAFSLoggingService
All Implemented Interfaces:
com.ibm.staf.service.STAFServiceInterfaceLevel3

public class SAFSLoggingService
extends java.lang.Object
implements com.ibm.staf.service.STAFServiceInterfaceLevel3

SAFSLoggingService is an external STAF service that handles standard SAFS logging.

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 AbstractLogFacility). 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.

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]
 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>]
 CLOSE       <facname> | ALL  [CAPXML]
 HELP        [MSGTYPE]
 VERSION
 

See Also:
AbstractLogFacility, SLSLogFacility, SAFSCustomLoggingService, "SAFSLogs Service User's Guide"

Nested Class Summary
 
Nested classes/interfaces inherited from interface com.ibm.staf.service.STAFServiceInterfaceLevel3
com.ibm.staf.service.STAFServiceInterfaceLevel3.InitInfo, com.ibm.staf.service.STAFServiceInterfaceLevel3.RequestInfo
 
Field Summary
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_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_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.
 
Constructor Summary
SAFSLoggingService()
           
 
Method Summary
 com.ibm.staf.STAFResult acceptRequest(com.ibm.staf.service.STAFServiceInterfaceLevel3.RequestInfo info)
          Handles service request from STAF.
static void debugPrintln(java.lang.String msg)
          Prints a line to the debug log if debugging is enabled.
static void debugPrintln(java.lang.String msg, java.lang.Exception e)
          Prints a message and Exception to the debug log if debugging is enabled.
static void debugPrintln(java.lang.String msg, com.ibm.staf.STAFResult r)
          Prints a message and STAFResult to the debug log if debugging is enabled.
 int init(com.ibm.staf.service.STAFServiceInterfaceLevel3.InitInfo info)
          Handles initializing this instance of the service for STAF.
 int term()
          Handles removing this service from STAF.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SLS_STAF_LOG_SERVICE_NAME

public 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. This is built based on the name of the service to guarantee it is unique.


SLS_SERVICE_MODE_LOCAL

public static final java.lang.String SLS_SERVICE_MODE_LOCAL
See Also:
Constant Field Values

SLS_SERVICE_MODE_REMOTE

public static final java.lang.String SLS_SERVICE_MODE_REMOTE
See Also:
Constant Field Values

SLS_SERVICE_OPTION_DIR

public static final java.lang.String SLS_SERVICE_OPTION_DIR
See Also:
Constant Field Values

SLS_SERVICE_OPTION_CUSTOMLOGGING

public static final java.lang.String SLS_SERVICE_OPTION_CUSTOMLOGGING
See Also:
Constant Field Values

SLS_SERVICE_OPTION_REMOTE

public static final java.lang.String SLS_SERVICE_OPTION_REMOTE
See Also:
Constant Field Values

SLS_SERVICE_OPTION_NAME

public static final java.lang.String SLS_SERVICE_OPTION_NAME
See Also:
Constant Field Values

SLS_SERVICE_REQUEST_HANDLEID

public static final java.lang.String SLS_SERVICE_REQUEST_HANDLEID
See Also:
Constant Field Values

SLS_SERVICE_REQUEST_INIT

public static final java.lang.String SLS_SERVICE_REQUEST_INIT
See Also:
Constant Field Values

SLS_SERVICE_REQUEST_QUERY

public static final java.lang.String SLS_SERVICE_REQUEST_QUERY
See Also:
Constant Field Values

SLS_SERVICE_REQUEST_LIST

public static final java.lang.String SLS_SERVICE_REQUEST_LIST
See Also:
Constant Field Values

SLS_SERVICE_REQUEST_SUSPENDLOG

public static final java.lang.String SLS_SERVICE_REQUEST_SUSPENDLOG
See Also:
Constant Field Values

SLS_SERVICE_REQUEST_RESUMELOG

public static final java.lang.String SLS_SERVICE_REQUEST_RESUMELOG
See Also:
Constant Field Values

SLS_SERVICE_REQUEST_LOGLEVEL

public static final java.lang.String SLS_SERVICE_REQUEST_LOGLEVEL
See Also:
Constant Field Values

SLS_SERVICE_REQUEST_LOGMESSAGE

public static final java.lang.String SLS_SERVICE_REQUEST_LOGMESSAGE
See Also:
Constant Field Values

SLS_SERVICE_REQUEST_CLOSE

public static final java.lang.String SLS_SERVICE_REQUEST_CLOSE
See Also:
Constant Field Values

SLS_SERVICE_REQUEST_HELP

public static final java.lang.String SLS_SERVICE_REQUEST_HELP
See Also:
Constant Field Values

SLS_SERVICE_REQUEST_VERSION

public static final java.lang.String SLS_SERVICE_REQUEST_VERSION
See Also:
Constant Field Values

SLS_SERVICE_PARM_ALL

public static final java.lang.String SLS_SERVICE_PARM_ALL
See Also:
Constant Field Values

SLS_SERVICE_PARM_TEXTLOG

public static final java.lang.String SLS_SERVICE_PARM_TEXTLOG
See Also:
Constant Field Values

SLS_SERVICE_PARM_XMLLOG

public static final java.lang.String SLS_SERVICE_PARM_XMLLOG
See Also:
Constant Field Values

SLS_SERVICE_PARM_TOOLLOG

public static final java.lang.String SLS_SERVICE_PARM_TOOLLOG
See Also:
Constant Field Values

SLS_SERVICE_PARM_CONSOLELOG

public static final java.lang.String SLS_SERVICE_PARM_CONSOLELOG
See Also:
Constant Field Values

SLS_SERVICE_PARM_LINKEDFAC

public static final java.lang.String SLS_SERVICE_PARM_LINKEDFAC
See Also:
Constant Field Values

SLS_SERVICE_PARM_OVERWRITE

public static final java.lang.String SLS_SERVICE_PARM_OVERWRITE
See Also:
Constant Field Values

SLS_SERVICE_PARM_CAPXML

public static final java.lang.String SLS_SERVICE_PARM_CAPXML
See Also:
Constant Field Values

SLS_SERVICE_PARM_SETTINGS

public static final java.lang.String SLS_SERVICE_PARM_SETTINGS
See Also:
Constant Field Values

SLS_SERVICE_PARM_DEBUG

public static final java.lang.String SLS_SERVICE_PARM_DEBUG
See Also:
Constant Field Values

SLS_SERVICE_PARM_INFO

public static final java.lang.String SLS_SERVICE_PARM_INFO
See Also:
Constant Field Values

SLS_SERVICE_PARM_WARN

public static final java.lang.String SLS_SERVICE_PARM_WARN
See Also:
Constant Field Values

SLS_SERVICE_PARM_ERROR

public static final java.lang.String SLS_SERVICE_PARM_ERROR
See Also:
Constant Field Values

SLS_SERVICE_PARM_MESSAGE

public static final java.lang.String SLS_SERVICE_PARM_MESSAGE
See Also:
Constant Field Values

SLS_SERVICE_PARM_DESCRIPTION

public static final java.lang.String SLS_SERVICE_PARM_DESCRIPTION
See Also:
Constant Field Values

SLS_SERVICE_PARM_MSGTYPE

public static final java.lang.String SLS_SERVICE_PARM_MSGTYPE
See Also:
Constant Field Values

SLS_SETTINGS_MODE_PREFIX

public static final java.lang.String SLS_SETTINGS_MODE_PREFIX
Prefix to the mode setting of this service in response to the LIST SETTINGS command.

See Also:
Constant Field Values

SLS_SETTINGS_REMOTE_MACHINE_PREFIX

public static final java.lang.String SLS_SETTINGS_REMOTE_MACHINE_PREFIX
Prefix to the remote machine setting of this service in response to the LIST SETTINGS command.

See Also:
Constant Field Values

SLS_SETTINGS_REMOTE_SERVICE_PREFIX

public static final java.lang.String SLS_SETTINGS_REMOTE_SERVICE_PREFIX
Prefix to the remote service setting of this service in response to the LIST SETTINGS command.

See Also:
Constant Field Values

SLS_SETTINGS_DEFAULT_DIR_PREFIX

public static final java.lang.String SLS_SETTINGS_DEFAULT_DIR_PREFIX
Prefix to the default directory setting of this service in response to the LIST SETTINGS command.

See Also:
Constant Field Values

SLS_SETTINGS_CUSTOM_LOGGING_PREFIX

public static final 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.

See Also:
Constant Field Values

SLS_STATES_TOOLLOG_PREFIX

public static final java.lang.String SLS_STATES_TOOLLOG_PREFIX
Prefix to the toollog state of this service in the result buffer of every LOGMESSAGE command.

See Also:
Constant Field Values

SLS_STATES_CONSOLELOG_PREFIX

public static final java.lang.String SLS_STATES_CONSOLELOG_PREFIX
Prefix to the consolelog state of this service in the result buffer of every LOGMESSAGE command.

See Also:
Constant Field Values

SLS_STATES_LOGLEVEL_PREFIX

public static final java.lang.String SLS_STATES_LOGLEVEL_PREFIX
Prefix to the log level state of this service in the result buffer of every LOGMESSAGE command.

See Also:
Constant Field Values
Constructor Detail

SAFSLoggingService

public SAFSLoggingService()
Method Detail

init

public final int init(com.ibm.staf.service.STAFServiceInterfaceLevel3.InitInfo info)
Handles initializing this instance of the service for STAF.

This service is registered under process name "STAF/Service/<ServiceName>".

Specified by:
init in interface com.ibm.staf.service.STAFServiceInterfaceLevel3

acceptRequest

public com.ibm.staf.STAFResult acceptRequest(com.ibm.staf.service.STAFServiceInterfaceLevel3.RequestInfo info)
Handles service request from STAF.

Specified by:
acceptRequest in interface com.ibm.staf.service.STAFServiceInterfaceLevel3

term

public final int term()
Handles removing this service from STAF.

All log facilities are forced to close.

Specified by:
term in interface com.ibm.staf.service.STAFServiceInterfaceLevel3

debugPrintln

public static void debugPrintln(java.lang.String msg)
Prints a line to the debug log if debugging is enabled.

Parameters:
msg - the message to print.

debugPrintln

public static void debugPrintln(java.lang.String msg,
                                com.ibm.staf.STAFResult r)
Prints a message and STAFResult to the debug log if debugging is enabled.

Parameters:
msg - the message to print.
t - the STAFResult to print.

debugPrintln

public static void debugPrintln(java.lang.String msg,
                                java.lang.Exception e)
Prints a message and Exception to the debug log if debugging is enabled.

Parameters:
msg - the message to print.
e - the Exception to print.