public abstract class STAFFileLogItem extends FileLogItem
The initialization of this log item clears existing STAF log with the same name.
Modifier and Type | Field and Description |
---|---|
protected ServiceDebugLog |
debugLog |
protected HandleInterface |
handle |
protected static java.lang.String |
LINEFEED |
protected static int |
SAFSLOG_MAJOR_VER |
protected static int |
SAFSLOG_MINOR_VER |
protected java.lang.String |
STAFVersion |
Constructor and Description |
---|
STAFFileLogItem(long mode,
java.lang.String parent,
java.lang.String file)
Creates a disabled
STAFFileLogItem with default name (file
name) and log level (LOGLEVEL_INFO ). |
STAFFileLogItem(java.lang.String name,
long mode,
boolean enabled,
java.lang.String parent,
java.lang.String file)
Creates a
STAFFileLogItem with the default log level
(LOGLEVEL_INFO ). |
Modifier and Type | Method and Description |
---|---|
protected void |
appendFinalLog(java.io.Writer out)
Allow subclasses to append information to the final destination log.
|
abstract void |
close()
Close this log.
|
protected void |
exportSTAFLog(java.io.File src)
Exports the message fields of all log records of a STAF log to this log
item's destination file.
|
protected void |
finalizeLogFile()
Finalizes the detination log file.
|
protected abstract java.util.List<java.lang.String> |
getCloseMessages()
Return the messages to write before the log is closed.
|
protected abstract java.util.List<java.lang.String> |
getInitMessages()
Return the messages to write after the log is initialized.
|
protected java.lang.String |
getMachineName()
STAF version 2 will use {STAF/Config/EffectiveMachine} to make log.
|
protected abstract java.lang.String |
getSTAFLogDirectory()
Returns the DIRECTORY setting of the STAF LOG service.
|
protected java.lang.String |
getTestName()
Strip the suffix of the test file to get the test name.
|
void |
init()
Initializes this log by clearing the STAF log with the same name, if any.
|
protected void |
prependFinalLog(java.io.Writer out)
Allow subclasses to prepend information to the final destination log.
|
protected java.lang.String |
readStringFromSTAFLog(java.io.DataInputStream in)
Read the next string from the STAF log.
|
protected long |
readUIntFromSTAFLog(java.io.DataInputStream in)
Reads the next "unsigned integer" from the input stream.
|
protected void |
setDebugLog(ServiceDebugLog debugLog) |
void |
setHandle(HandleInterface h)
Set the STAF handle of this log item.
|
protected com.ibm.staf.STAFResult |
stafLogLog(java.lang.String message)
Logs a message of Info level to the associated STAF log.
|
protected com.ibm.staf.STAFResult |
stafLogLog(java.lang.String message,
java.lang.String level)
Logs a message to the STAF log associated with this log item.
|
protected com.ibm.staf.STAFResult |
stafLogRequest(java.lang.String request)
Submits a request to the instance of STAF LOG service loaded by the SAFS
logging service.
|
protected void |
write(java.lang.String msg)
Write a message to the log.
|
protected void |
writeCloseMessages()
Write message to log before it is closed.
|
protected void |
writeInitMessages()
Write messages to log after it is initialized.
|
fileExists, getAbsolutePath, getFileSpec, getParentDir, isFileSpecAbsolute, setParentDir
dateTime, isClosed, logMessage
protected static final int SAFSLOG_MAJOR_VER
protected static final int SAFSLOG_MINOR_VER
protected static final java.lang.String LINEFEED
protected java.lang.String STAFVersion
protected HandleInterface handle
protected ServiceDebugLog debugLog
public STAFFileLogItem(java.lang.String name, long mode, boolean enabled, java.lang.String parent, java.lang.String file)
STAFFileLogItem
with the default log level
(LOGLEVEL_INFO
).
name
- the name of this log. If null
, file name is
used as the name.mode
- the type of this log (LOGMODE
constant
defined by AbstractLogFacility
).enabled
- true
to enable this log; false
to disable.parent
- the parent directory for this log.file
- the file spec of this log.public STAFFileLogItem(long mode, java.lang.String parent, java.lang.String file)
STAFFileLogItem
with default name (file
name) and log level (LOGLEVEL_INFO
).
mode
- the type of this log (LOGMODE
constant
defined by AbstractLogFacility
).parent
- the parent directory for this log.file
- the file spec of this log.public void setHandle(HandleInterface h)
h
- the new STAF handle.public void init()
public abstract void close() throws STAFLogException
close
in class LogItem
STAFLogException
- if this method failed for any reason.protected abstract java.util.List<java.lang.String> getInitMessages()
protected abstract java.util.List<java.lang.String> getCloseMessages()
protected void write(java.lang.String msg)
protected void writeInitMessages()
init()
.protected void writeCloseMessages()
close()
.protected java.lang.String getTestName()
protected com.ibm.staf.STAFResult stafLogRequest(java.lang.String request)
request
- the service request to submit.protected com.ibm.staf.STAFResult stafLogLog(java.lang.String message, java.lang.String level)
message
- the MESSAGE option value of the LOG request.level
- the LEVEL option value of the LOG request.protected com.ibm.staf.STAFResult stafLogLog(java.lang.String message)
message
- the MESSAGE option value of the LOG request.protected void finalizeLogFile() throws STAFLogException
SAFSLogException
- if failed to finalize the log file.STAFLogException
protected abstract java.lang.String getSTAFLogDirectory()
protected void prependFinalLog(java.io.Writer out)
out
- protected void appendFinalLog(java.io.Writer out)
out
- protected void exportSTAFLog(java.io.File src) throws java.io.IOException
This method parsed the STAF log file directly for the log messages and writes them to the destination file. In terms of performance and memory consumption, it is better than indirectly querying the log content via STAF LOG service.
src
- contains full path to the source STAF log file.java.io.IOException
- if file related error occured.protected java.lang.String readStringFromSTAFLog(java.io.DataInputStream in) throws java.io.IOException
Strings are saved in the STAF log as byte data, with the number of bytes (saved as 4-byte long unsigned integer) preceeding the actual data.
in
- the STAF log input stream.java.io.IOException
protected long readUIntFromSTAFLog(java.io.DataInputStream in) throws java.io.IOException
This method reads the next 4 bytes from the input stream, and convert them to a long (because java does not support unsigned data types), using the first byte as the highest byte and treating each byte as unsigned. For example:
00 00 01 01 -> 257 00 00 00 FF -> 255
in
- the STAF log input stream.long
equal to the unsigned integer converted
from the bytes.java.io.IOException
protected void setDebugLog(ServiceDebugLog debugLog)
protected java.lang.String getMachineName()
Copyright © SAS Institute. All Rights Reserved.