org.safs.staf.service.logging
Class STAFXmlLogItem

java.lang.Object
  extended by org.safs.logging.LogItem
      extended by org.safs.logging.FileLogItem
          extended by org.safs.staf.service.logging.STAFFileLogItem
              extended by org.safs.staf.service.logging.STAFXmlLogItem

public class STAFXmlLogItem
extends STAFFileLogItem

This class encapsulates a standard SAFS xml file log implemented using STAF. Log messages are written in a temporary STAF log while the log is running. Upon closing, the content of of the STAF log is formatted to the SAFS xml log standard and exported to the destination log file.

Note that logging function of this class is for local use only.


Field Summary
protected  boolean capXML
          TRUE if the XML log should be capped at closure.
 
Fields inherited from class org.safs.staf.service.logging.STAFFileLogItem
handle, LINEFEED, SAFSLOG_MAJOR_VER, SAFSLOG_MINOR_VER
 
Fields inherited from class org.safs.logging.LogItem
closed, enabled, level, mode, name
 
Constructor Summary
STAFXmlLogItem(java.lang.String file)
          Creates a disabled STAFXmlLogItem with default name (file name) and log level (LOGLEVEL_INFO), and empty parent directory.
STAFXmlLogItem(java.lang.String parent, java.lang.String file)
          Creates a disabled STAFXmlLogItem with default name (file name) and log level (LOGLEVEL_INFO).
STAFXmlLogItem(java.lang.String name, java.lang.String parent, java.lang.String file)
          Creates a disabled STAFXmlLogItem with default log level (LOGLEVEL_INFO).
 
Method Summary
protected  void appendFinalLog(java.io.Writer out)
          Override superclass prepend to provide a valid XML header if capXML is true.
 void close()
          Close this log if enabled and open.
 boolean getCapXML()
          Returns the current setting of whether the XML log will be capped on closure.
 void init()
          Initializes this log and writes the log open message.
 void logMessage(java.lang.String msg)
          Logs a message in standard SAFS text log format if enabled and open.
 void logMessage(java.lang.String msg, int msgType)
          Logs a message in standard SAFS text log format if enabled and open.
 void logMessage(java.lang.String msg, java.lang.String desc, int msgType)
          Logs a message in standard SAFS xml log format if enabled and open.
protected  void prependFinalLog(java.io.Writer out)
          Override superclass prepend to provide a valid XML header if capXML is true.
 void setCapXML(boolean capbool)
          Set true if this log should be "capped" (made valid XML) upon closure.
 
Methods inherited from class org.safs.staf.service.logging.STAFFileLogItem
exportSTAFLog, finalizeLogFile, readStringFromSTAFLog, readUIntFromSTAFLog, setHandle, stafLogLog, stafLogLog, stafLogRequest
 
Methods inherited from class org.safs.logging.FileLogItem
fileExists, getAbsolutePath, getFileSpec, getParentDir, isFileSpecAbsolute, setParentDir
 
Methods inherited from class org.safs.logging.LogItem
dateTime, isClosed
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

capXML

protected boolean capXML
TRUE if the XML log should be capped at closure. Capping the log provides final XML header and footer text to make the XML valid.

Constructor Detail

STAFXmlLogItem

public STAFXmlLogItem(java.lang.String name,
                      java.lang.String parent,
                      java.lang.String file)
Creates a disabled STAFXmlLogItem with default log level (LOGLEVEL_INFO).

The type of this log item is always LOGMODE_SAFS_XML.

Parameters:
name - the name of this log.
parent - the parent directory for this log.
file - the file spec of this log.

STAFXmlLogItem

public STAFXmlLogItem(java.lang.String parent,
                      java.lang.String file)
Creates a disabled STAFXmlLogItem with default name (file name) and log level (LOGLEVEL_INFO).

The type of this log item is always LOGMODE_SAFS_XML.

Parameters:
parent - the parent directory for this log.
file - the file spec of this log.

STAFXmlLogItem

public STAFXmlLogItem(java.lang.String file)
Creates a disabled STAFXmlLogItem with default name (file name) and log level (LOGLEVEL_INFO), and empty parent directory.

The type of this log item is always LOGMODE_SAFS_XML.

Parameters:
file - the file spec of this log.
Method Detail

init

public void init()
Initializes this log and writes the log open message.

Overrides:
init in class STAFFileLogItem

setCapXML

public void setCapXML(boolean capbool)
Set true if this log should be "capped" (made valid XML) upon closure.

Parameters:
capbool -

getCapXML

public boolean getCapXML()
Returns the current setting of whether the XML log will be capped on closure.

Returns:
true if the log is set to be XML capped on closure.

logMessage

public void logMessage(java.lang.String msg,
                       java.lang.String desc,
                       int msgType)
Logs a message in standard SAFS xml log format if enabled and open.

Specified by:
logMessage in class LogItem
Parameters:
msg - the message to log.
desc - additional description to log.
msgType - the int identifier of the type of message being logged.

logMessage

public void logMessage(java.lang.String msg,
                       int msgType)
Logs a message in standard SAFS text log format if enabled and open.

Parameters:
msg - the message to log.
msgType - the int identifier of the type of message being logged.

logMessage

public void logMessage(java.lang.String msg)
Logs a message in standard SAFS text log format if enabled and open.

Message type defaults to GENERIC_MESSAGE.

Parameters:
msg - the message to log.

close

public void close()
           throws STAFLogException
Close this log if enabled and open.

Specified by:
close in class STAFFileLogItem
Throws:
STAFLogException - if this method failed for any reason.

prependFinalLog

protected void prependFinalLog(java.io.Writer out)
Override superclass prepend to provide a valid XML header if capXML is true. This routine does nothing if capXML is false.

Overrides:
prependFinalLog in class STAFFileLogItem
Parameters:
out - PrintWriter

appendFinalLog

protected void appendFinalLog(java.io.Writer out)
Override superclass prepend to provide a valid XML header if capXML is true. This routine does nothing if capXML is false.

Overrides:
appendFinalLog in class STAFFileLogItem
Parameters:
out - PrintWriter