Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

com.flexstor.common.util
Class DiagnosticBase  view DiagnosticBase download DiagnosticBase.java

java.lang.Object
  extended bycom.flexstor.common.util.DiagnosticCategoryI
      extended bycom.flexstor.common.util.DiagnosticBase
Direct Known Subclasses:
Diagnostic

public class DiagnosticBase
extends DiagnosticCategoryI

Revision 1.6 2000-09-28 : 22:51:00 Visesh This class now extends DiagnosticCategoryI instead of DiagnosticCategory Removed constructors particular to DiagnosticCategory when it was in the hiearchy Changed all method definations by changing the type of parameters from DiagnosticCategoryI to DiagnosticCategory DiagnosticBase is a utility class for tracing and debugging. It is not intended for error and exception handling. It provides methods to print, trace, and warn and also to check for conditions. One or more output streams can be registered so that output can be saved in a file and shown on the console simultaneously.

This is the base class without dependencies providing the main functionality. Diagnostic adds the capability of using a properties file for configuration.


Field Summary
protected static boolean bChecking
           
protected static boolean bOutput
           
protected static boolean bOutputConsole
           
protected static boolean bPrintThreadId
           
protected static boolean bPrintTime
           
protected static boolean bPropertiesLoaded
           
protected static java.util.Properties categoryTraceLevels
           
protected static java.lang.String COL_SEPARARTOR
          Default time format: year-month-day 24hour:minute:second:millisecond
protected static java.lang.String DEFAULT_TIME_FORMAT
           
protected static java.util.Vector fileTraceCategories
           
protected static java.lang.String indent
           
protected static int outLevel
           
protected static java.io.PrintWriter[] outputDevices
           
protected static java.util.Hashtable outputDevicesCategory
           
protected static java.io.OutputStream systemOut
           
protected static java.text.SimpleDateFormat timeFormat
           
protected static java.util.Vector traceCategories
           
 
Fields inherited from class com.flexstor.common.util.DiagnosticCategoryI
APPSERVER_ARCHIVE, APPSERVER_IMPORT, APPSERVER_MAIN, APPSERVER_QMANAGER, APPSERVER_SERVICES, ASSET_REG, ASSET_VERSIONS, CAT_ARCHIVE, CAT_CLASSGEN, CAT_CLASSLDR, CAT_EXPORT, CAT_GATEWAY, CAT_IMPORT, CAT_OAS, CAT_PROCESS, CAT_REPORT, CAT_SCRIPT_SVC, CAT_SEND, CAT_THREAD_MGR, categories, REGISTRY, SETTINGS
 
Constructor Summary
DiagnosticBase()
           
 
Method Summary
static void addOutputDevice(DiagnosticCategory category, java.io.OutputStream outstream)
          Adds an exclusive OutputStream as an output device for the specified category
static void addOutputDevice(DiagnosticCategory category, java.io.PrintWriter writer)
          Adds an exclusive writer as an output device for the specified category
static void addOutputDevice(java.io.OutputStream outstream)
          Adds an OutputStream as an output device
static void addOutputDevice(java.io.Writer writer)
          Adds a writer as an output device
static void addTraceCategory(DiagnosticCategory category)
          Adds a category for tracing and warnings.
static void check(boolean bCondition, java.lang.String sDescription)
          Check a condition within a method body.
static void enableChecking(boolean enable)
          Enables or disables the checking of conditions in precondition() and check()
static void enableOutput(boolean enable)
          Enables or disables output generation
static void enableTimeStamp(boolean enable)
          Enables or disables the time stamp print
static void fail(java.lang.Exception ex)
          Shorthand for causing an exception if the code reaches an unexpected location by rethrowing the exception
protected static java.lang.String getThreadId()
          Prints text to the output devices without a line feed.
protected static int getTraceLevel()
           
static int getTraceLevel(DiagnosticCategory category)
           
static boolean isOutputEnabled(DiagnosticCategory category)
           
protected static boolean isOutputLevel(DiagnosticCategory category, int nLevel)
           
protected static boolean isRegisteredCategory(DiagnosticCategory category)
           
static void needException()
          Marks places where an exception is needed.
static void precondition(boolean bCondition, java.lang.String sDescription)
          Assert a precondition before a method body run.
protected static void println(DiagnosticCategory category, java.lang.String sText)
          Checks if an output device is registered for this category, if so, print to it, otherwise use general output devices.
static void println(java.lang.String sText)
          Prints text to the output devices with a line feed.
static void printMemStatus(boolean bRunGc)
          Prints the currently available memory.
protected static void printOneLine(java.io.PrintWriter writer, java.lang.String sTime, java.lang.String sText)
          Print one line to one PrintWriter.
protected static void printOneStackTrace(java.io.PrintWriter writer, java.lang.String sTime, java.lang.Throwable t)
          Print a stack trace of the Throwable to one PrintWriter.
static void printStackTrace()
          Print a diagnostic stack trace of the current thread to the output devices.
static void printStackTrace(DiagnosticCategory category, int nLevel, java.lang.Throwable t)
          Print a stack trace of the Throwable to the output devices if the category is enabled and the trace level is high enough.
static void printStackTrace(DiagnosticCategory category, java.lang.Throwable t)
          Print a stack trace of the Throwable to the output devices if the category is enabled.
static void printStackTrace(int nLevel, java.lang.Throwable t)
          Print a stack trace of the Throwable to the output devices if the trace level is high enough.
static void printStackTrace(java.lang.Throwable t)
          Print a stack trace of the Throwable to the output devices.
static void removeTraceCategory(DiagnosticCategory category)
          Removes a category for tracing and warnings.
static void setTraceLevel(int nLevel)
          Set the minimum threshold for trace and warning output.
static void trace(DiagnosticCategory category, int nLevel, java.lang.String sDescription)
          Output a trace if the category is enabled and general output is enabled
static void trace(DiagnosticCategory category, java.lang.String sDescription)
          Output a trace if the category and general output is enabled
static void trace(int nLevel, java.lang.String sDescription)
          Output a trace if the threshold nLevel is high enough and general output is enabled
static void warn(DiagnosticCategory category, boolean bCondition, java.lang.String sDescription)
          Output a warning if the category is enabled, and a condition is true, and general output is enabled
static void warn(DiagnosticCategory category, int nLevel, boolean bCondition, java.lang.String sDescription)
          Output a warning if the category is enabled, the threshold level is high enough, and a condition is true, and general output is enabled
static void warn(DiagnosticCategory category, java.lang.String sDescription)
          Output a warning if the category is enabled, and general output is enabled
static void warn(int nLevel, boolean bCondition, java.lang.String sDescription)
          Output a warning if the threshold level is high enough, and a condition is true, and general output is enabled
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

indent

protected static final java.lang.String indent
See Also:
Constant Field Values

outLevel

protected static int outLevel

bPropertiesLoaded

protected static boolean bPropertiesLoaded

bOutput

protected static boolean bOutput

bOutputConsole

protected static boolean bOutputConsole

bPrintTime

protected static boolean bPrintTime

bPrintThreadId

protected static boolean bPrintThreadId

bChecking

protected static boolean bChecking

traceCategories

protected static java.util.Vector traceCategories

fileTraceCategories

protected static java.util.Vector fileTraceCategories

categoryTraceLevels

protected static java.util.Properties categoryTraceLevels

COL_SEPARARTOR

protected static final java.lang.String COL_SEPARARTOR
Default time format: year-month-day 24hour:minute:second:millisecond

See Also:
Constant Field Values

DEFAULT_TIME_FORMAT

protected static final java.lang.String DEFAULT_TIME_FORMAT
See Also:
Constant Field Values

timeFormat

protected static java.text.SimpleDateFormat timeFormat

outputDevices

protected static java.io.PrintWriter[] outputDevices

outputDevicesCategory

protected static java.util.Hashtable outputDevicesCategory

systemOut

protected static final java.io.OutputStream systemOut
Constructor Detail

DiagnosticBase

public DiagnosticBase()
Method Detail

addOutputDevice

public static void addOutputDevice(java.io.OutputStream outstream)
Adds an OutputStream as an output device


addOutputDevice

public static void addOutputDevice(java.io.Writer writer)
Adds a writer as an output device


addOutputDevice

public static void addOutputDevice(DiagnosticCategory category,
                                   java.io.OutputStream outstream)
Adds an exclusive OutputStream as an output device for the specified category


addOutputDevice

public static void addOutputDevice(DiagnosticCategory category,
                                   java.io.PrintWriter writer)
Adds an exclusive writer as an output device for the specified category


enableOutput

public static void enableOutput(boolean enable)
Enables or disables output generation


enableChecking

public static void enableChecking(boolean enable)
Enables or disables the checking of conditions in precondition() and check()


enableTimeStamp

public static void enableTimeStamp(boolean enable)
Enables or disables the time stamp print


setTraceLevel

public static void setTraceLevel(int nLevel)
Set the minimum threshold for trace and warning output. 0 is highest level +maxint is lowest level Setting this level to -1 will effectively turn off traces and warnings.


getTraceLevel

protected static int getTraceLevel()

getTraceLevel

public static int getTraceLevel(DiagnosticCategory category)

addTraceCategory

public static void addTraceCategory(DiagnosticCategory category)
Adds a category for tracing and warnings.


removeTraceCategory

public static void removeTraceCategory(DiagnosticCategory category)
Removes a category for tracing and warnings.


precondition

public static void precondition(boolean bCondition,
                                java.lang.String sDescription)
                         throws DiagnosticPreconditionException
Assert a precondition before a method body run. Use this to describe assumed state and parameter values. A precondition is raised if the given condition is not true. The check is only performed if checking is enabled.


check

public static void check(boolean bCondition,
                         java.lang.String sDescription)
                  throws DiagnosticCheckException
Check a condition within a method body. Use this to describe assumed results and state after internal operations. A check is raised if the given condition is not true.


fail

public static void fail(java.lang.Exception ex)
                 throws java.lang.Exception
Shorthand for causing an exception if the code reaches an unexpected location by rethrowing the exception


needException

public static void needException()
                          throws DiagnosticCheckException
Marks places where an exception is needed.


warn

public static void warn(int nLevel,
                        boolean bCondition,
                        java.lang.String sDescription)
Output a warning if the threshold level is high enough, and a condition is true, and general output is enabled


warn

public static void warn(DiagnosticCategory category,
                        boolean bCondition,
                        java.lang.String sDescription)
Output a warning if the category is enabled, and a condition is true, and general output is enabled


warn

public static void warn(DiagnosticCategory category,
                        java.lang.String sDescription)
Output a warning if the category is enabled, and general output is enabled


warn

public static void warn(DiagnosticCategory category,
                        int nLevel,
                        boolean bCondition,
                        java.lang.String sDescription)
Output a warning if the category is enabled, the threshold level is high enough, and a condition is true, and general output is enabled


trace

public static void trace(int nLevel,
                         java.lang.String sDescription)
Output a trace if the threshold nLevel is high enough and general output is enabled


trace

public static void trace(DiagnosticCategory category,
                         java.lang.String sDescription)
Output a trace if the category and general output is enabled


trace

public static void trace(DiagnosticCategory category,
                         int nLevel,
                         java.lang.String sDescription)
Output a trace if the category is enabled and general output is enabled


printOneStackTrace

protected static void printOneStackTrace(java.io.PrintWriter writer,
                                         java.lang.String sTime,
                                         java.lang.Throwable t)
Print a stack trace of the Throwable to one PrintWriter. Used internally.


printStackTrace

public static void printStackTrace(java.lang.Throwable t)
Print a stack trace of the Throwable to the output devices.


printStackTrace

public static void printStackTrace()
Print a diagnostic stack trace of the current thread to the output devices.


printStackTrace

public static void printStackTrace(DiagnosticCategory category,
                                   java.lang.Throwable t)
Print a stack trace of the Throwable to the output devices if the category is enabled.


printStackTrace

public static void printStackTrace(int nLevel,
                                   java.lang.Throwable t)
Print a stack trace of the Throwable to the output devices if the trace level is high enough.


printStackTrace

public static void printStackTrace(DiagnosticCategory category,
                                   int nLevel,
                                   java.lang.Throwable t)
Print a stack trace of the Throwable to the output devices if the category is enabled and the trace level is high enough.


println

public static void println(java.lang.String sText)
Prints text to the output devices with a line feed.


printOneLine

protected static void printOneLine(java.io.PrintWriter writer,
                                   java.lang.String sTime,
                                   java.lang.String sText)
Print one line to one PrintWriter. Used internally.


println

protected static void println(DiagnosticCategory category,
                              java.lang.String sText)
Checks if an output device is registered for this category, if so, print to it, otherwise use general output devices. Prints text to the output devices with a line feed.


getThreadId

protected static java.lang.String getThreadId()
Prints text to the output devices without a line feed.


printMemStatus

public static void printMemStatus(boolean bRunGc)
Prints the currently available memory.


isRegisteredCategory

protected static boolean isRegisteredCategory(DiagnosticCategory category)

isOutputLevel

protected static boolean isOutputLevel(DiagnosticCategory category,
                                       int nLevel)

isOutputEnabled

public static boolean isOutputEnabled(DiagnosticCategory category)