com.ls.service.log
Class PerformanceLogger

java.lang.Object
  |
  +--com.ls.service.log.PerformanceLogger

public class PerformanceLogger
extends Object

This class is used for performance logging of the agent platform activity. If the class gets instantiated, the current system time is stored internally. Each log message then is extended by the difference between the current system time and the starting time (in milliseconds). A new start time is set, if logStart(java.lang.String, int, java.lang.String, java.lang.String) is used for logging.

Note: Keep in mind, that logging to a file (and even creating log messages) costs time and might falsify the results!

Note: The class needs no special synchronization, because the underlying ILogger class is synchronized.

Version:
$Revision: 1.4 $
Author:
Last modified by $Author: JBogenschuetz $

Constructor Summary
PerformanceLogger()
          Empty constructor.
PerformanceLogger(ILogger logger)
          Constructor including the ILogger where the log messages get stored.
PerformanceLogger(String logFileName)
          Constructor that includes trying to open the file where the log messages get stored.
PerformanceLogger(String logFileName, Map replacementMap)
          Constructor that includes trying to open the file where the log messages get stored.
 
Method Summary
 void log(String className, int logType, String methodName, String logNotice)
          Logs a given notice including the difference between the current system time and the start time, if the given logLevel is equal or more important than the log level of the used ILogger.
 void logStart(String className, int logType, String methodName, String logNotice)
          Logs a given notice including the current system time in milliseconds, if the given logLevel is equal or more important than the log level of the used ILogger.
 boolean setLogFile(String logFileName)
          changes the log file to another file
 void setLogLevel(int logLevel)
          Sets the log level of the used agent log.
 void setLogLevel(String logLevel)
          Sets the log level of the used agent log.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

PerformanceLogger

public PerformanceLogger()
                  throws BaseRuntimeException
Empty constructor. If this constructor is used all log messages will be outputted to the console (as long, as the setLogFile(String) method is not called).
Throws:
BaseRuntimeException - If the LoggerFactory fails to create an ILogger instance
See Also:
LoggerFactory, ILogger

PerformanceLogger

public PerformanceLogger(String logFileName)
                  throws BaseRuntimeException
Constructor that includes trying to open the file where the log messages get stored.
Parameters:
logFileName - name of the log file
Throws:
BaseRuntimeException - If the LoggerFactory fails to create an ILogger instance
See Also:
LoggerFactory, ILogger

PerformanceLogger

public PerformanceLogger(String logFileName,
                         Map replacementMap)
                  throws BaseRuntimeException
Constructor that includes trying to open the file where the log messages get stored.
Parameters:
logFileName - name of the log file
replacementMap - map containing variable/value pairs for substitutions in the log file name
Throws:
BaseRuntimeException - If the LoggerFactory fails to create an ILogger instance
See Also:
LoggerFactory, ILogger

PerformanceLogger

public PerformanceLogger(ILogger logger)
Constructor including the ILogger where the log messages get stored.
Parameters:
logger - log file to be used
Method Detail

setLogLevel

public void setLogLevel(int logLevel)
Sets the log level of the used agent log. This log level is used to determine, if a message of a certain level has to be logged: If the log level of a log message is at least as important the log file's log level, the message is written, otherwise it is ignored.
Parameters:
logLevel - log level as an integer (use constants defined in ILogger like ILogger.WARNING)

setLogLevel

public void setLogLevel(String logLevel)
                 throws LogException
Sets the log level of the used agent log. This log level is used to determine, if a message of a certain level has to be logged: If the log level of a log message is at least as important the log file's log level, the message is written, otherwise it is ignored.
Parameters:
logLevel - name of one of the in ILogger defined constants (e.g. "error"), case is ignored
Throws:
LogException - If given log level is null or unknown

logStart

public void logStart(String className,
                     int logType,
                     String methodName,
                     String logNotice)
Logs a given notice including the current system time in milliseconds, if the given logLevel is equal or more important than the log level of the used ILogger.
Note: Independent of the log level, a new start time is set before trying to write the log message. As a result of this, you might find no notice in the log file, that the start time got resetted.
Parameters:
className - name of the class in which the log message was created
logType - level of the message (SysLog.TRACE5 ... SysLog.ERROR) determining, if the notice gets logged or ignored
methodName - name of the method in which the log message was created
logNotice - content of the log message

log

public void log(String className,
                int logType,
                String methodName,
                String logNotice)
Logs a given notice including the difference between the current system time and the start time, if the given logLevel is equal or more important than the log level of the used ILogger.
Parameters:
className - name of the class in which the log message was created
logType - level of the message (SysLog.TRACE5 ... SysLog.ERROR) determining, if the notice gets logged or ignored
methodName - name of the method in which the log message was created
logNotice - content of the log message

setLogFile

public boolean setLogFile(String logFileName)
changes the log file to another file
Parameters:
logFileName - name of the file to be used as log file
Returns:
false, if the new log file could not be opened or the old one could not be closed; true else