com.voytechs.util
Class DebugEnvironment

java.lang.Object
  extended by com.voytechs.util.DebugEnvironment

public class DebugEnvironment
extends java.lang.Object

The class controls the debug environment of jNetStream application. By calling turnOnDebug() you enable debug logging from various logging components of the application. In addition the static isDebug() method returns true. Most modules check if isDebug() == true and if it does, then that is the time that they log their debug output.

You can use the getDebugList().add() method and class names for which you would like debug messages to be displayed. Only those logging subsystems with the class name or more specifically the ones that end with the name specified have their logging turn on.

Empty list turns on global debug option in the logging system and all messages are logged. This may be overwhelming and is generally used to lookup which debug messages the user is interested in and after that the output is restricted.

In addition, the debug environment can be further customized using standard Apache CommonsLogging and Log4j configuration options or what ever the logging system utilized by the user. All debug messages are logged using a CommonsLogging library which is logging system independent and can be overriden by the user.

Author:
Mark Bednarczyk, Sly Technologies, Inc.

Constructor Summary
DebugEnvironment()
           
 
Method Summary
static void debug(Log logger, java.lang.String string)
          Splits the supplied string into individual lines and logs each line seperately with the supplied logger.
static java.util.List getDebugList()
          List of class names, or more specifically that name in the supplied string.
static boolean isDebugEnabled()
          Check this flag if debug was requested to be turned on, if false, its not worth logging any debug messages.
static void setDebugEnabled(boolean debug)
          Manually sets the debug flag.
static void turnOnDebug(java.lang.String prefix)
          Turns on all debugging and enables specific requested loggers for debuging based on the debug list, using getDebugList().add() method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DebugEnvironment

public DebugEnvironment()
Method Detail

getDebugList

public static java.util.List getDebugList()
List of class names, or more specifically that name in the supplied string. Each string in the list is used in a String.endsWith() comparison. This allows only the shortest amount of matching end of the string to be supplied to turn on debugging. If too many loggers are enabled you may have to specify a longer string upto the entire connanical class name if neccessary.

Returns:
Mutable list that you should add your requested class names for debuggging.

isDebugEnabled

public static boolean isDebugEnabled()
Check this flag if debug was requested to be turned on, if false, its not worth logging any debug messages. Only when this flag is on should debug message be generated and logged for efficiency reasons.

Returns:
Returns the debug.

setDebugEnabled

public static void setDebugEnabled(boolean debug)
Manually sets the debug flag. This flag is checked by many jNetStream components which use it to determine if logging messages should be sent or not for efficiency reasons.

Parameters:
debug - The debug to set.

debug

public static void debug(Log logger,
                         java.lang.String string)
Splits the supplied string into individual lines and logs each line seperately with the supplied logger. This version expect commons.logging.log logger.

Parameters:
logger - logger to use for logging each line of the string.
string - multiline string to be split up and logged individually.

turnOnDebug

public static void turnOnDebug(java.lang.String prefix)
Turns on all debugging and enables specific requested loggers for debuging based on the debug list, using getDebugList().add() method.