org.jurvis.logging
Class JvLoggingUtilities

java.lang.Object
  extended by org.jurvis.logging.JvLoggingUtilities

public final class JvLoggingUtilities
extends Object

Various utility methods useful in logging.

Author:
Neil W. Weber

Constructor Summary
JvLoggingUtilities()
           
 
Method Summary
static void debugElapsedTime(org.apache.commons.logging.Log log, String methodName, long startTime)
          Log the amount of elapsed time consumed by a method.
static String formatElapsedTime(String name, long startTime)
          Format the elapsed time since startTime.
static void infoElapsedTime(org.apache.commons.logging.Log log, String methodName, long startTime)
          Log the amount of elapsed time consumed by a method.
static void logElapsedTime(org.apache.commons.logging.Log log, String methodName, long startTime)
          Log the amount of elapsed time consumed by a method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JvLoggingUtilities

public JvLoggingUtilities()
Method Detail

formatElapsedTime

public static String formatElapsedTime(String name,
                                       long startTime)
Format the elapsed time since startTime.

Parameters:
name - the name to report
startTime - the time in milliseconds when the clock started clicking
Returns:
the formatted elapsed time

logElapsedTime

public static void logElapsedTime(org.apache.commons.logging.Log log,
                                  String methodName,
                                  long startTime)
Log the amount of elapsed time consumed by a method. Typical usage:
 long startTime = log.isInfoEnabled() ? System.currentTimeMillis() : 0;

 try
 {
     if (log.isDebugEnabled())
        log.debug("testing connection to " + delegate.getServerName());

     delegate.testConnection();
 }
 finally
 {
     logElapsedTime(log, "testConnection", startTime);
 }
 

Parameters:
log - the log to log to
methodName - the name of the method
startTime - the time in milliseconds when the method was started

infoElapsedTime

public static void infoElapsedTime(org.apache.commons.logging.Log log,
                                   String methodName,
                                   long startTime)
Log the amount of elapsed time consumed by a method. Typical usage:
 long startTime = log.isInfoEnabled() ? System.currentTimeMillis() : 0;

 try
 {
     if (log.isDebugEnabled())
        log.debug("testing connection to " + delegate.getServerName());

     delegate.testConnection();
 }
 finally
 {
     infoElapsedTime(log, "testConnection", startTime);
 }
 

Parameters:
log - the log to log to
methodName - the name of the method
startTime - the time in milliseconds when the method was started

debugElapsedTime

public static void debugElapsedTime(org.apache.commons.logging.Log log,
                                    String methodName,
                                    long startTime)
Log the amount of elapsed time consumed by a method. This only differs from logElapsedTime in the logging level. Typical usage:
 long startTime = log.isDebugEnabled() ? System.currentTimeMillis() : 0;

 try
 {
     if (log.isDebugEnabled())
        log.debug("testing connection to " + delegate.getServerName());

     delegate.testConnection();
 }
 finally
 {
     debugElapsedTime(log, "testConnection", startTime);
 }
 

Parameters:
log - the log to log to
methodName - the name of the method
startTime - the time in milliseconds when the method was started


Copyright © 1999-2004 Neil W. Weber. All Rights Reserved.