Platform SDK Java 8.5 API Reference

com.genesyslab.platform.logging
Class DefaultFileHeaderProvider

java.lang.Object
  extended by com.genesyslab.platform.commons.log.AbstractLogEnabled
      extended by com.genesyslab.platform.logging.DefaultFileHeaderProvider
All Implemented Interfaces:
ILogEnabled, FileHeaderProvider, java.lang.Cloneable

public class DefaultFileHeaderProvider
extends AbstractLogEnabled
implements FileHeaderProvider, java.lang.Cloneable

The default implementation of FileHeaderProvider.


Constructor Summary
  DefaultFileHeaderProvider()
          Default constructor.
protected DefaultFileHeaderProvider(DefaultFileHeaderProvider arg)
          Copy constructor.
  DefaultFileHeaderProvider(java.lang.String theApplicationName, java.lang.String theApplicationHost, int theApplicationId, int theApplicationType, ILogger logger)
          Constructor.
 
Method Summary
 void applyConfiguration(LogConfiguration configuration)
          This method is called on the copy of class, during the procedure of configuring logger.
 DefaultFileHeaderProvider clone()
          Creates a new object that is a copy of the current instance.
protected  java.lang.String formatElapsedTime(long milliSeconds)
           
protected  java.lang.String formatElapsedTime2(long milliSeconds)
           
protected  void formatHeader(java.lang.StringBuilder targetBuilder, java.lang.String fileName)
          This method is called from GetFileHeader method.
protected  java.lang.String getApplicationHost()
          The Application Host to be used in the file header.
protected  int getApplicationId()
          The Application Id to be used in the file header.
protected  java.lang.String getApplicationName()
          The Application Name to be used in the file header.
protected  int getApplicationType()
          The Application Type to be used in the file header.
 java.lang.String getFileHeader(java.lang.String fileName)
          This method is called for obtaining the log file header.
protected  java.lang.String getSystemPropery(java.lang.String propertyName)
           
protected  void onEnableLogging(ILogger logger)
          Overrides AbstractLogEnabled.onEnableLogging.
protected  void setApplicationHost(java.lang.String name)
           
protected  void setApplicationId(int id)
           
protected  void setApplicationName(java.lang.String name)
           
protected  void setApplicationType(int type)
           
protected  void writeAssemblyUseInfo(java.lang.StringBuilder targetBuilder, java.lang.String lineFormat)
          This method is used for writing version info about loaded PSDK jars to file header.
protected  void writeMemorySection(java.lang.StringBuilder targetBuilder, java.lang.String lineFormat)
          This method writes the section to StringBuilder which appends the strings which describe Memory Usage.
protected  void writeProcessTimeSection(java.lang.StringBuilder targetBuilder, java.lang.String lineFormat)
          This method writes the section to StringBuilder which appends the strings which describe Process Start Time and Process Run Time.
 
Methods inherited from class com.genesyslab.platform.commons.log.AbstractLogEnabled
enableLogging, getLogger
 
Methods inherited from class java.lang.Object
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultFileHeaderProvider

public DefaultFileHeaderProvider()
Default constructor. Initializes DefaultFileHeaderProvider object with new instance of NullLogger.


DefaultFileHeaderProvider

public DefaultFileHeaderProvider(java.lang.String theApplicationName,
                                 java.lang.String theApplicationHost,
                                 int theApplicationId,
                                 int theApplicationType,
                                 ILogger logger)
Constructor.

Parameters:
theApplicationName - The Application Name to be used in file header
theApplicationHost - The Application Host to be used in file header
theApplicationId - The Application Id to be used in file header
theApplicationType - The Application Id to be used in file header
logger - Internal logger. Used for initialization of AbstractLogEnabled.Logger

DefaultFileHeaderProvider

protected DefaultFileHeaderProvider(DefaultFileHeaderProvider arg)
Copy constructor.

Parameters:
arg - argument to copy
Method Detail

getApplicationName

protected java.lang.String getApplicationName()
The Application Name to be used in the file header.


setApplicationName

protected void setApplicationName(java.lang.String name)

getApplicationHost

protected java.lang.String getApplicationHost()
The Application Host to be used in the file header.


setApplicationHost

protected void setApplicationHost(java.lang.String name)

getApplicationType

protected int getApplicationType()
The Application Type to be used in the file header.


setApplicationType

protected void setApplicationType(int type)

getApplicationId

protected int getApplicationId()
The Application Id to be used in the file header.


setApplicationId

protected void setApplicationId(int id)

onEnableLogging

protected void onEnableLogging(ILogger logger)
Overrides AbstractLogEnabled.onEnableLogging.

Overrides:
onEnableLogging in class AbstractLogEnabled
Parameters:
logger - ILogger to be used

clone

public DefaultFileHeaderProvider clone()
Creates a new object that is a copy of the current instance.

Specified by:
clone in interface FileHeaderProvider
Overrides:
clone in class java.lang.Object
Returns:
A new object that is a copy of this instance
See Also:
Cloneable

applyConfiguration

public void applyConfiguration(LogConfiguration configuration)
This method is called on the copy of class, during the procedure of configuring logger. The instance for which this method was called will be used for obtaining the header of file.

Specified by:
applyConfiguration in interface FileHeaderProvider
Parameters:
configuration - The configuration to apply

getFileHeader

public java.lang.String getFileHeader(java.lang.String fileName)
This method is called for obtaining the log file header.

Specified by:
getFileHeader in interface FileHeaderProvider
Parameters:
fileName - The name of file to be written
Returns:
The string which will be used as header for the log file or segment

formatHeader

protected void formatHeader(java.lang.StringBuilder targetBuilder,
                            java.lang.String fileName)
This method is called from GetFileHeader method. The default implementation writes the standard log file header. This method relies on WriteProcessTimeSection and WriteMemorySection for filling such properties as Memory Usage, Process Start Time and Process Run time.

Parameters:
targetBuilder - The StringBuilder where all info is being appended. The result header will be targetBuilder.toString() value.
fileName - The name of file the header for which is being constructed.

writeAssemblyUseInfo

protected void writeAssemblyUseInfo(java.lang.StringBuilder targetBuilder,
                                    java.lang.String lineFormat)
This method is used for writing version info about loaded PSDK jars to file header. Override this method to change its behavior.

Parameters:
targetBuilder - The target StringBuilder
lineFormat - The proposed formatting line. Current version: "{0,-35}{1}"

writeProcessTimeSection

protected void writeProcessTimeSection(java.lang.StringBuilder targetBuilder,
                                       java.lang.String lineFormat)
This method writes the section to StringBuilder which appends the strings which describe Process Start Time and Process Run Time. This method calls the code which requires the calling code to have FullTrust permission. If this is unacceptable - override this method in derived class.

Parameters:
targetBuilder - The target StringBuilder
lineFormat - the proposed format for line being appended. This line is supposed to contain 2 parts: header (index - 0) and body (index - 1).

writeMemorySection

protected void writeMemorySection(java.lang.StringBuilder targetBuilder,
                                  java.lang.String lineFormat)
This method writes the section to StringBuilder which appends the strings which describe Memory Usage. This method calls the code which requires the calling code to have FullTrust permission. If this is unacceptable - override this method in derived class.

Parameters:
targetBuilder - The target StringBuilder
lineFormat - the proposed format for line being appended. This line is supposed to contain 2 parts: header (index - 0) and body (index - 1).

getSystemPropery

protected java.lang.String getSystemPropery(java.lang.String propertyName)

formatElapsedTime

protected java.lang.String formatElapsedTime(long milliSeconds)

formatElapsedTime2

protected java.lang.String formatElapsedTime2(long milliSeconds)

Platform SDK Java 8.5 API Reference

Send comments on this topicTechpubs.webadmin@genesys.com.
Document version: 8.5.302.00
Copyright © 2006–2017 Genesys Telecommunications Laboratories, Inc. All rights reserved.