public class LogUtilities extends STAFRequester
The subclass would minimally overload the primary logMessage function--the one that actually implements the logging code--and intercept logMessage calls. The subclass function would call its super.logMessage to perform the normal SAFSLOGS logging and then evaluate the returned String to see if it is expected to write to the native tool log and/or console.
Modifier and Type | Field and Description |
---|---|
protected boolean |
copyLogClass
flag for sending/copying messages to static org.safs.Log class.
|
protected boolean |
initialized
flag for instance initialization state
|
protected java.lang.String |
lastNamedLogFacility
Stores the name of the last used LogFacility when logging.
|
static java.lang.String |
LOG_ERROR
Generic error return value from logMessage routines.
|
protected int |
logLevel
curent log level as retrieved from SAFSLOGS.
|
staf
Constructor and Description |
---|
LogUtilities()
Noop Constructor
User must provide an initialized STAFHelper via superclass
before the instance can be effective. |
LogUtilities(STAFHelper helper)
Constructor with pre-registered STAF handle
|
LogUtilities(STAFHelper helper,
boolean copyLogClass)
Constructor with pre-registered STAF handle and flag for using the static Log class.
|
Modifier and Type | Method and Description |
---|---|
protected boolean |
checkInitialized()
convenience routine to throw a LogException when uninitialized.
|
void |
closeLogFacility(java.lang.String facname)
Closes a specified LogFacility or ALL LogFacilities via the SAFSLOGS service.
|
void |
consoleLog(java.lang.String formattedMessage,
java.lang.String description)
Subclasses override to log to a proprietary tool-dependent console.
|
boolean |
getCopyLogClass()
Check the present state of our copyLogClass flag.
|
java.lang.String |
getLastNamedLogFacility()
returns the name of the last used LogFacility for logging.
|
void |
initLogFacility(java.lang.String facname,
long facmode)
Initialize a new LogFacility via the SAFSLOGS service.
|
void |
initLogFacility(java.lang.String facname,
long facmode,
java.lang.String linkedfac)
Initialize a new LogFacility via the SAFSLOGS service.
|
void |
initLogFacility(java.lang.String facname,
long facmode,
java.lang.String alttextlog,
java.lang.String altxmllog,
java.lang.String linkedfac)
Initialize a new LogFacility via the SAFSLOGS service.
|
java.lang.String |
logMessage(java.lang.String facname,
java.lang.String msg)
Log a message to the specified LogFacility via the SAFSLOGS service.
|
java.lang.String |
logMessage(java.lang.String facname,
java.lang.String msg,
int msgType)
Log a message to the specified LogFacility via the SAFSLOGS service.
|
java.lang.String |
logMessage(java.lang.String facname,
java.lang.String msg,
int msgType,
java.lang.String description)
Log a message to the specified LogFacility via the SAFSLOGS service.
|
java.lang.String |
logMessage(java.lang.String facname,
java.lang.String msg,
java.lang.String description)
Log a message to the specified LogFacility via the SAFSLOGS service.
|
java.lang.String |
logMessage(java.lang.String facname,
java.lang.String msg,
java.lang.String description,
int msgType)
Log a message to the specified LogFacility via the SAFSLOGS service.
|
static void |
main(java.lang.String[] args)
Some self-test diagnostics...does it really work :?
|
protected void |
sendLogClassMessage(java.lang.String msg,
java.lang.String description,
int msgType)
Copy the message to the static org.safs.Log class if enabled.
|
void |
setCopyLogClass(boolean copyLogClass)
Set or Reset the flag to enable logging to org.safs.Log
This Log class is primarily used during development and debugging and is not
normally used during production testing.
|
void |
setLastNamedLogFacility(java.lang.String lastNamedLogFacility) |
void |
toolLog(int messageType,
java.lang.String formattedMessage,
java.lang.String description)
Subclasses override to log to their proprietary tool-dependent log.
|
getSTAFHelper, setSTAFHelper
public static final java.lang.String LOG_ERROR
protected boolean initialized
protected boolean copyLogClass
protected int logLevel
protected java.lang.String lastNamedLogFacility
This is useful for subclasses like ApacheLogUtilities that bridge to our logging mechanism but do not provide a facname parameter in their APIs.
public LogUtilities()
STAFRequester
before the instance can be effective.public LogUtilities(STAFHelper helper)
helper
- -- an initialized STAFHelper for talking with STAF.public LogUtilities(STAFHelper helper, boolean copyLogClass)
helper
- -- an initialized STAFHelper for talking with STAF.copyLogClass
- -- flag as to whether or not messages should be forwarded to
the static org.safs.Log class That Log class is primarily used during development
and debugging and is not normally used during production testing.public java.lang.String getLastNamedLogFacility()
This is useful for subclasses like ApacheLogUtilities that bridge to our logging mechanism but do not provide a facname parameter in their APIs.
public void setLastNamedLogFacility(java.lang.String lastNamedLogFacility)
lastNamedLogFacility
- String, the name of the last used LogFacility for loggingpublic void setCopyLogClass(boolean copyLogClass)
copyLogClass
- -- true to forward messages to org.safs.Logpublic boolean getCopyLogClass()
protected boolean checkInitialized() throws LogException
LogException
public void initLogFacility(java.lang.String facname, long facmode, java.lang.String alttextlog, java.lang.String altxmllog, java.lang.String linkedfac) throws LogException
facname
- -- String name for this log facility.facmode
- -- long OR'd values of enabled logs. Valid values are the
various LOGMODE_ constants defined in AbstractLogFacility
.alttextlog
- -- alternative String name for an enabled SAFS TEXT log.
If null the default name for the text log as defined in AbstractLogFacility
will be used.altxmllog
- -- alternative String name for an enabled SAFS XML log.
If null the default name for the XML log as defined in AbstractLogFacility
will be used.linkedfac
- -- NOT YET IMPLEMENTEDLogException
public void initLogFacility(java.lang.String facname, long facmode) throws LogException
facname
- -- String name for this log facility.facmode
- -- long OR'd values of enabled logs. Valid values are the
various LOGMODE_ constants defined in AbstractLogFacility
.LogException
public void initLogFacility(java.lang.String facname, long facmode, java.lang.String linkedfac) throws LogException
facname
- -- String name for this log facility.facmode
- -- long OR'd values of enabled logs. Valid values are the
various LOGMODE_ constants defined in AbstractLogFacility
.linkedfac
- -- NOT YET IMPLEMENTEDLogException
public void closeLogFacility(java.lang.String facname) throws LogException
facname
- -- String name of an open LogFacility in SAFSLOGS. If this
parameter is null, then we will close ALL open LogFacilities in the service.LogException
protected void sendLogClassMessage(java.lang.String msg, java.lang.String description, int msgType)
msg
- -- the message to sendmsgType
- the local msgType. This will be converted to the appropriate
message type for the Log class.public java.lang.String logMessage(java.lang.String facname, java.lang.String msg, java.lang.String description, int msgType)
Tool-dependent subclass implementations would minimally overload this function to intercept the call. Subclasses would then call this function via super.logMessage and evaluate the returned String to see if the tool- dependent subclass is expected to log to the native tool log and/or console.
facname
- -- String name of an open LogFacility in SAFSLOGS.msg
- -- String text of the message to log.description
- -- optional String text of additional details for the message.msgType
- -- int message type identifier constant as defined in
AbstractLogFacility
.If no error occurred, the returned String informs the caller if native tool logging or console logging is enabled and at what log level. The caller, presumably a commercial automation tool, can then determine if it should log the message to the native tool log and/or console.
public java.lang.String logMessage(java.lang.String facname, java.lang.String msg, int msgType, java.lang.String description)
facname
- -- String name of an open LogFacility in SAFSLOGS.msg
- -- String text of the message to log.msgType
- -- int message type identifier constant as defined in
AbstractLogFacility
.description
- -- optional String text of additional details for the message.public java.lang.String logMessage(java.lang.String facname, java.lang.String msg, int msgType)
facname
- -- String name of an open LogFacility in SAFSLOGS.msg
- -- String text of the message to log.msgType
- -- int message type identifier constant as defined in
AbstractLogFacility
.public java.lang.String logMessage(java.lang.String facname, java.lang.String msg, java.lang.String description)
facname
- -- String name of an open LogFacility in SAFSLOGS.msg
- -- String text of the message to log.description
- -- optional String text of additional details for the message.public java.lang.String logMessage(java.lang.String facname, java.lang.String msg)
facname
- -- String name of an open LogFacility in SAFSLOGS.msg
- -- String text of the message to log.public void toolLog(int messageType, java.lang.String formattedMessage, java.lang.String description)
messageType
- int type of to be loggedformattedMessage
- String the message to be loggeddescription
- String optional description about the message
being loggedpublic void consoleLog(java.lang.String formattedMessage, java.lang.String description)
formattedMessage
- String the message to be loggeddescription
- String optional description about the message
being loggedpublic static void main(java.lang.String[] args)
Copyright © SAS Institute. All Rights Reserved.