ecologylab.generic
Class Debug

java.lang.Object
  extended by ecologylab.generic.Debug
Direct Known Subclasses:
AbstractClientManager, AppFrameworkTranslations, ApplicationEnvironment, Assets, AssetsTranslations, Authenticator, BaudRateComboModel, CFMessagesTranslations, CFServicesClientExample, CollectionTools, ConnectionAdapter, ConsoleUtils, DataTransferTools, DLL, DownloadableFileToDisk, ElementState, ElementStateSAXHandler, ElementTypeTranslations, Environment.The, Files, FloatSetElement, FloatWeightSet, GPS, GPSDataUpdater, ICDLTranslations, ImageTools, LockFile, NameSpaceDecl, NetTools, NewPorterStemmer, NIOCore, NIOServerBase, NIOTools, NSDLTranslationSpace, Optimizations, OutOfMemoryErrorHandler, Palette, ParsedURL, PrefEditorWidgets, PrefixPhrase, PrefTranslations, Projection, PropertiesAndDirectories, PURLConnection, ReflectionTools, ResourcePool, RESTTranslationSpace, RssTranslations, ScalarType, ServerToClientConnection, ServicesClientBase, ServicesServerBase, SessionId, SimpleDownloadProcessor, StringBuffersPool, StringTools, TestMaps, TraceSlots, TranslationSpace, TranslationSpace.TranslationEntry, TypeRegistry, ZipDownload

public class Debug
extends java.lang.Object

A developer-friendly base class and toolset for logging debug messages. Supports a threshold, aka level with 2 levels of granularity: 1) global
2) on a per class basis
This levels are configured via runtime startup params ( via the JavaScript prefs mechanisms for applet versions) in the form of 1) debug_global_level = 4; 2) debug_levels = "Parser 3; HTMLPage 2; CollageOp 37";

Author:
andruid

Constructor Summary
protected Debug()
           
 
Method Summary
static java.lang.String classSimpleName(java.lang.Class thatClass)
          This actually seems to be much more efficient than Class.
static void closeLoggingFile()
           
 void debug(java.lang.CharSequence message)
          Print a debug message that starts with this.toString().
 void debug(int messageLevel, java.lang.CharSequence message)
          Print a debug message that starts with the abbreviated class name of this, but only if messageLevel is greater than the debug level for this class (see above).
static void debug(java.lang.Object o, java.lang.CharSequence message, java.lang.Exception e)
           
 void debug(java.lang.StringBuffer message)
          Print a debug message that starts with this.toString().
 void debugA(java.lang.CharSequence message)
          Print a debug message that starts with the abbreviated class name of this.
 void debugA(int messageLevel, java.lang.CharSequence message)
           
 void debugA(java.lang.StringBuffer message)
          Print a debug message that starts with the abbreviated class name of this.
 void debugI(java.lang.CharSequence message)
           
 void debugI(int messageLevel, java.lang.CharSequence message)
           
 void debugI(java.lang.StringBuffer message)
           
 void error(java.lang.CharSequence message)
          Print a message about an error, starting with this.toString().
static void error(java.lang.Object that, java.lang.CharSequence message)
          Print a message about an error, starting with that.toString().
 java.lang.String getClassName()
           
static java.lang.String getClassName(java.lang.Object o)
           
static boolean getInteractive()
           
 java.lang.String getPackageName()
           
static java.lang.String getPackageName(java.lang.Class thatClass)
           
static java.lang.String getPackageName(java.lang.Object o)
           
static void initialize()
          Global hi watermark.
 int level()
           
static int level(java.lang.Object that)
           
static int level(java.lang.String className)
           
static boolean logToFile()
           
static void print(char c)
           
static void print(java.lang.CharSequence message)
           
static void println(java.lang.CharSequence message)
           
static void println(int messageLevel, java.lang.CharSequence message)
           
static void println(java.lang.Object o, java.lang.CharSequence message)
           
static void println(java.lang.Object that, int messageLevel, java.lang.CharSequence message)
           
static void println(java.lang.String className, java.lang.CharSequence message)
           
static void println(java.lang.String className, int messageLevel, java.lang.CharSequence message)
           
static void printlnA(java.lang.Class c, java.lang.CharSequence message)
          Print a debug message, starting with the abbreviated class name.
static void printlnA(java.lang.Object that, java.lang.CharSequence message)
          Print a debug message, starting with the abbreviated class name of the object.
static void printlnA(java.lang.Object that, int messageLevel, java.lang.CharSequence message)
           
static void printlnI(java.lang.CharSequence message)
           
static void printlnI(int messageLevel, java.lang.CharSequence message)
           
static void printlnI(java.lang.Object o, java.lang.CharSequence message)
           
static void printlnI(java.lang.Object that, int messageLevel, java.lang.CharSequence message)
           
static void setLoggingFile(java.lang.String loggingFilePath)
           
 boolean show(int messageLevel)
           
static boolean show(java.lang.Object that, int messageLevel)
          Evaluates the same conditional as Debug usually does implicitly, for explicit use in special static Debug printing scenarios.
 java.lang.String superString()
           
static void toggleInteractive()
           
 java.lang.String toString()
           
static java.lang.String toString(java.lang.Object o)
           
 void warning(java.lang.CharSequence message)
          Print a message about a warning, starting with this.toString().
static void warning(java.lang.Object that, java.lang.CharSequence message)
          Print a message about a warning, starting with that.toString().
 void weird(java.lang.CharSequence message)
          Print a message about something that should never happen, starting with this.toString().
static void weird(java.lang.Object that, java.lang.CharSequence message)
          Print a message about something that should never happen, starting with that.toString().
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

Debug

protected Debug()
Method Detail

initialize

public static void initialize()
Global hi watermark. debug() messages with a level less than or equal to this will get printed out.


level

public final int level()

level

public static final int level(java.lang.Object that)

level

public static final int level(java.lang.String className)

println

public static void println(int messageLevel,
                           java.lang.CharSequence message)
Parameters:
messageLevel - If less than or equal to the static level, message will get logged. Otherwise, the statement will be ignored.

printlnI

public static void printlnI(int messageLevel,
                            java.lang.CharSequence message)

println

public static void println(java.lang.Object o,
                           java.lang.CharSequence message)

println

public static void println(java.lang.String className,
                           java.lang.CharSequence message)

printlnI

public static void printlnI(java.lang.Object o,
                            java.lang.CharSequence message)

printlnI

public static void printlnI(java.lang.CharSequence message)

println

public static void println(java.lang.CharSequence message)

print

public static void print(char c)

print

public static void print(java.lang.CharSequence message)

printlnA

public static void printlnA(java.lang.Object that,
                            java.lang.CharSequence message)
Print a debug message, starting with the abbreviated class name of the object.


printlnA

public static void printlnA(java.lang.Class c,
                            java.lang.CharSequence message)
Print a debug message, starting with the abbreviated class name.


classSimpleName

public static java.lang.String classSimpleName(java.lang.Class thatClass)
This actually seems to be much more efficient than Class. getSimpleName(), because we are smart about using lazy evaluation and caching results in a HashMap.

Returns:
the abbreviated name of the class - without the package qualifier.

getPackageName

public static java.lang.String getPackageName(java.lang.Class thatClass)
Returns:
the abbreviated name of the class - without the package qualifier.

getClassName

public static java.lang.String getClassName(java.lang.Object o)
Returns:
the abbreviated name of the class - without the package qualifier.

getClassName

public java.lang.String getClassName()
Returns:
the abbreviated name of this class - without the package qualifier.

getPackageName

public static java.lang.String getPackageName(java.lang.Object o)
Returns:
the package name of the class - without the package qualifier.

getPackageName

public java.lang.String getPackageName()
Returns:
the package name of this class - without the package qualifier.

toString

public java.lang.String toString()
Overrides:
toString in class java.lang.Object

superString

public java.lang.String superString()

toString

public static java.lang.String toString(java.lang.Object o)

debug

public final void debug(java.lang.CharSequence message)
Print a debug message that starts with this.toString().


error

public void error(java.lang.CharSequence message)
Print a message about an error, starting with this.toString().


warning

public void warning(java.lang.CharSequence message)
Print a message about a warning, starting with this.toString().


weird

public void weird(java.lang.CharSequence message)
Print a message about something that should never happen, starting with this.toString().


error

public static void error(java.lang.Object that,
                         java.lang.CharSequence message)
Print a message about an error, starting with that.toString().


warning

public static void warning(java.lang.Object that,
                           java.lang.CharSequence message)
Print a message about a warning, starting with that.toString().


weird

public static void weird(java.lang.Object that,
                         java.lang.CharSequence message)
Print a message about something that should never happen, starting with that.toString().


debug

public final void debug(java.lang.StringBuffer message)
Print a debug message that starts with this.toString().


debugA

public final void debugA(java.lang.CharSequence message)
Print a debug message that starts with the abbreviated class name of this.


debugA

public final void debugA(java.lang.StringBuffer message)
Print a debug message that starts with the abbreviated class name of this.


debugI

public final void debugI(java.lang.CharSequence message)

debugI

public final void debugI(java.lang.StringBuffer message)

show

public static final boolean show(java.lang.Object that,
                                 int messageLevel)
Evaluates the same conditional as Debug usually does implicitly, for explicit use in special static Debug printing scenarios.


show

public boolean show(int messageLevel)

debug

public final void debug(int messageLevel,
                        java.lang.CharSequence message)
Print a debug message that starts with the abbreviated class name of this, but only if messageLevel is greater than the debug level for this class (see above).


debugA

public final void debugA(int messageLevel,
                         java.lang.CharSequence message)

println

public static final void println(java.lang.Object that,
                                 int messageLevel,
                                 java.lang.CharSequence message)

println

public static final void println(java.lang.String className,
                                 int messageLevel,
                                 java.lang.CharSequence message)

printlnA

public static final void printlnA(java.lang.Object that,
                                  int messageLevel,
                                  java.lang.CharSequence message)

printlnI

public static final void printlnI(java.lang.Object that,
                                  int messageLevel,
                                  java.lang.CharSequence message)

debugI

public final void debugI(int messageLevel,
                         java.lang.CharSequence message)

debug

public static final void debug(java.lang.Object o,
                               java.lang.CharSequence message,
                               java.lang.Exception e)

toggleInteractive

public static final void toggleInteractive()

setLoggingFile

public static final void setLoggingFile(java.lang.String loggingFilePath)

closeLoggingFile

public static void closeLoggingFile()

getInteractive

public static boolean getInteractive()
Returns:
state of the global flag for printing "interactive" debug statements.

logToFile

public static boolean logToFile()