com.isti.util
Class ClientLogViaCfgProps

java.lang.Object
  extended by com.isti.util.ErrorMessageMgr
      extended by com.isti.util.ClientLogViaCfgProps
All Implemented Interfaces:
ErrorMsgMgrIntf

public class ClientLogViaCfgProps
extends ErrorMessageMgr

Class ClientLogViaCfgProps creates a log file using 'CfgPropItem' objects. The usage will usually be to extend this class, call the 'createLogFile()' method, and then make use of the 'logObj' variable.


Field Summary
protected static java.lang.String baseWriteDirStr
          Base dir for write-access files (for 'fromBaseDir()' methods).
 CfgPropItem clientConsoleLevelProp
          Message level for console output.
 CfgPropItem clientLogFileLevelProp
          Message level for log file output.
 CfgPropItem clientLogFileNameProp
          Name of the log file.
 CfgPropItem consoleFilesMaxAgeInDays
          Console files maximum age in days (0=infinite).
 CfgPropItem consoleFilesSwitchIntvlDays
          Switch interval for console files, in days.
 CfgPropItem consoleRedirectFileNameProp
          Name of the console output redirect file.
protected  java.io.PrintStream consoleRedirectStream
          Output stream for redirected console output.
 CfgProperties logFileProps
          Configuration-properties object holding the log-file items.
 CfgPropItem logFilesMaxAgeInDaysProp
          Maximum age for log files (days, 0=infinite).
protected  LogFile logObj
          Log-file object.
 
Constructor Summary
ClientLogViaCfgProps()
          Creates an object for creating a log file using 'CfgPropItem' objects.
ClientLogViaCfgProps(CfgProperties cfgPropsObj)
          Creates an object for creating a log file using 'CfgPropItem' objects.
ClientLogViaCfgProps(CfgProperties cfgPropsObj, java.lang.Object groupSelObj)
          Creates an object for creating a log file using 'CfgPropItem' objects.
 
Method Summary
 void addLogFilePropItems(CfgProperties cfgPropsObj)
          Adds the log-file items to the given configuration-properties object.
 void addLogFilePropItems(CfgProperties cfgPropsObj, java.lang.Object groupSelObj)
          Adds the log-file items to the given configuration-properties object.
 void closeConsoleRedirectStream()
          Closes the console-redirect object created via the 'createLogFile()' method.
 void closeLogFile()
          Closes the log-file object created via the 'createLogFile()' method.
 boolean createLogFile(boolean abortOnErrorFlag)
          Creates a log file and sets it up using the configuration-property item objects.
static java.lang.String fromBaseDir(java.lang.String pathStr)
          Converts the given pathname to a pathname relative to the current write-access base directory.
static java.lang.String fromBaseDir(java.lang.String pathStr, boolean subOnEmptyFlag)
          Converts the given pathname to a pathname relative to the current write-access base directory.
static java.lang.String getBaseWriteDirStr()
          Returns the base-directory-path string for write-access files.
 java.io.PrintStream getConsoleRedirectStreamObj()
          Returns the console-redirect object created via the 'createLogFile()' method.
 LogFile getLogFileObj()
          Returns the log-file object created via the 'createLogFile()' method.
static void setBaseWriteDirStr(java.lang.String dirStr)
          Sets the base-directory-path string for write-access files.
 void setGroupSelObj(java.lang.Object groupSelObj)
          Sets the group-selection object for the log-file items.
 
Methods inherited from class com.isti.util.ErrorMessageMgr
clearErrorMessageString, clearFetchedErrorMessage, enterErrorMessageString, getErrorMessageFlag, getErrorMessageString, getUnfetchedMessageFlag, setErrorMessageString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logObj

protected LogFile logObj
Log-file object.


consoleRedirectStream

protected java.io.PrintStream consoleRedirectStream
Output stream for redirected console output.


baseWriteDirStr

protected static java.lang.String baseWriteDirStr
Base dir for write-access files (for 'fromBaseDir()' methods).


logFileProps

public final CfgProperties logFileProps
Configuration-properties object holding the log-file items.


consoleRedirectFileNameProp

public final CfgPropItem consoleRedirectFileNameProp
Name of the console output redirect file.


clientLogFileNameProp

public final CfgPropItem clientLogFileNameProp
Name of the log file.


clientLogFileLevelProp

public final CfgPropItem clientLogFileLevelProp
Message level for log file output.


clientConsoleLevelProp

public final CfgPropItem clientConsoleLevelProp
Message level for console output.


logFilesMaxAgeInDaysProp

public final CfgPropItem logFilesMaxAgeInDaysProp
Maximum age for log files (days, 0=infinite).


consoleFilesSwitchIntvlDays

public final CfgPropItem consoleFilesSwitchIntvlDays
Switch interval for console files, in days.


consoleFilesMaxAgeInDays

public final CfgPropItem consoleFilesMaxAgeInDays
Console files maximum age in days (0=infinite).

Constructor Detail

ClientLogViaCfgProps

public ClientLogViaCfgProps()
Creates an object for creating a log file using 'CfgPropItem' objects.


ClientLogViaCfgProps

public ClientLogViaCfgProps(CfgProperties cfgPropsObj,
                            java.lang.Object groupSelObj)
Creates an object for creating a log file using 'CfgPropItem' objects.

Parameters:
cfgPropsObj - the configuration-properties object to use.
groupSelObj - the configuration-group-selection object to use, or null for none.

ClientLogViaCfgProps

public ClientLogViaCfgProps(CfgProperties cfgPropsObj)
Creates an object for creating a log file using 'CfgPropItem' objects.

Parameters:
cfgPropsObj - the configuration-properties object to use.
Method Detail

addLogFilePropItems

public final void addLogFilePropItems(CfgProperties cfgPropsObj,
                                      java.lang.Object groupSelObj)
Adds the log-file items to the given configuration-properties object.

Parameters:
cfgPropsObj - the configuration-properties object to use.
groupSelObj - the configuration-group-selection object to use, or null for none.

addLogFilePropItems

public final void addLogFilePropItems(CfgProperties cfgPropsObj)
Adds the log-file items to the given configuration-properties object.

Parameters:
cfgPropsObj - the configuration-properties object to use.

setGroupSelObj

public final void setGroupSelObj(java.lang.Object groupSelObj)
Sets the group-selection object for the log-file items.

Parameters:
groupSelObj - the configuration-group-selection object to use, or null for none.

createLogFile

public boolean createLogFile(boolean abortOnErrorFlag)
Creates a log file and sets it up using the configuration-property item objects. A redirected console output stream may also be setup.

Parameters:
abortOnErrorFlag - if true then this method will return immediately after the first error is flagged (without creating the log file); if false then this method will always create the log file.
Returns:
'true' if successful, false if an error occurred (in which case an error message will be sent to the console and may be fetched via the 'getErrorMessageString()' method).

getLogFileObj

public LogFile getLogFileObj()
Returns the log-file object created via the 'createLogFile()' method.

Returns:
A 'LogFile' object, or null if none has been created.

closeLogFile

public void closeLogFile()
Closes the log-file object created via the 'createLogFile()' method.


getConsoleRedirectStreamObj

public java.io.PrintStream getConsoleRedirectStreamObj()
Returns the console-redirect object created via the 'createLogFile()' method.

Returns:
A 'PrintStream' object for console output, or null if none has been created.

closeConsoleRedirectStream

public void closeConsoleRedirectStream()
Closes the console-redirect object created via the 'createLogFile()' method.


setBaseWriteDirStr

public static void setBaseWriteDirStr(java.lang.String dirStr)
Sets the base-directory-path string for write-access files.

Parameters:
dirStr - base-directory-path string for write-access files, or an empty string or null for none.

getBaseWriteDirStr

public static java.lang.String getBaseWriteDirStr()
Returns the base-directory-path string for write-access files.

Returns:
The base-directory-path string for write-access files, or an empty string if none is setup.

fromBaseDir

public static java.lang.String fromBaseDir(java.lang.String pathStr,
                                           boolean subOnEmptyFlag)
Converts the given pathname to a pathname relative to the current write-access base directory. If no write-access base directory is setup or if the given pathname is absolute (or a URL) then the original pathname string is returned.

Parameters:
pathStr - the pathname string to use.
subOnEmptyFlag - if true and the given pathname is null or an empty string and a write-access base directory is setup then the write-access base directory path is returned; if false and the given pathname is null or an empty string then the original pathname is returned.
Returns:
The converted pathname string; or the original pathname string if not converted.

fromBaseDir

public static java.lang.String fromBaseDir(java.lang.String pathStr)
Converts the given pathname to a pathname relative to the current write-access base directory. If no write-access base directory is setup or if the given pathname is absolute (or a URL) then the original pathname string is returned.

Parameters:
pathStr - the pathname string to use.
Returns:
The converted pathname string; or the original pathname string if not converted.