|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object scale.common.Debug
public class Debug
A class for aiding in debuging.
$Id: Debug.java,v 1.37 2007-01-04 16:58:27 burrill Exp $
Copyright 2006 by the Scale Compiler Group,
Department of Computer Science
University of Massachusetts,
Amherst MA. 01003, USA
All Rights Reserved.
Use Debug.trace(...)
to decide if debug trace
information should be printed. The standard way of using this
class is to:
public static boolean classTrace = false;in the class that you wish to be able to trace.
private boolean trace;in the class as well.
trace = Debug.trace("routine name", classTrace, level);to the class constructor where the level is some intger. Or,
this.trace = classTrace || Debug.debug(level);for classes that operate over more than one routine at a time,
if (trace) System.out.println(...);to generate the trace information.
Use Debug.debug(level)
to decide if extra validity
tests should be performed or to print more detailed warnings, etc.
The debug level is meant for displaying general debugging information. A debug level of 1 causes validity checking at various places of the compiler. A level of 2 causes the output of general information. A level of 3 causes the output of some large tables.
Field Summary | |
---|---|
static int |
FULL
Debug level FULL. |
static int |
MEDIUM
Debug level between MINIMUM and FULL. |
static int |
MINIMUM
Debug level minimum. |
static int |
OFF
Debug level off. |
Method Summary | |
---|---|
static boolean |
debug(int level)
Return true if the debug level is greater than or equal to the given level. |
static java.lang.String |
formatInt(long value,
int size)
Return the string representation of a long integer value. |
static int |
getDebugLevel()
Return the debug level value. |
static java.lang.String |
getReportName()
Get the report name. |
static boolean |
printMessage(java.lang.String msg)
Print out the specified message. |
static boolean |
printMessage(java.lang.String msg,
java.lang.Object o)
Print out the specified message followed by the object. |
static boolean |
printMessage(java.lang.String msg,
java.lang.Object o,
int indent)
Print out the specified message followed by the object. |
static boolean |
printStackTrace()
Print out a stack trace. |
static boolean |
printStackTrace(java.lang.Throwable ex)
Print out the specified stack trace. |
static void |
setDebugLevel(int level)
Set the debug level. |
static void |
setReportName(java.lang.String name)
Set the report name. |
static boolean |
trace(java.lang.String name,
boolean flag,
int level)
Return true if the report name is the same as the specified name and the flag argument is true, or the debug level is greater than or equal to the given level. |
static long |
trackMemory()
Return the amount of memory used in bytes. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int OFF
public static final int MINIMUM
public static final int MEDIUM
public static final int FULL
Method Detail |
---|
public static void setDebugLevel(int level)
level
- a positive integer control the debug levelpublic static void setReportName(java.lang.String name)
name
- is the name to be tracedpublic static java.lang.String getReportName()
public static int getDebugLevel()
public static final boolean debug(int level)
level
- the debug level
public static final boolean trace(java.lang.String name, boolean flag, int level)
name
- is name to be tracedflag
- is the (class) trace flaglevel
- is the debug level
public static boolean printStackTrace()
assert
Java statement.
public static boolean printStackTrace(java.lang.Throwable ex)
assert
Java statement.
ex
- is the exception to be displayed
public static boolean printMessage(java.lang.String msg)
assert
Java statement.
msg
- is the message
public static boolean printMessage(java.lang.String msg, java.lang.Object o)
null
only the message is printed. This
method is designed so that it can be used with the
assert
Java statement.
msg
- is the messageo
- is the object
public static boolean printMessage(java.lang.String msg, java.lang.Object o, int indent)
null
only the message is printed. This
method is designed so that it can be used with the
assert
Java statement.
msg
- is the messageo
- is the objectindent
- specifies the number of spaces to output before the
message
public static long trackMemory()
public static java.lang.String formatInt(long value, int size)
size
characters,
pre-appended with blanks as necessary. If the value cannot be
represented in the space provided, a string of asterisks is
returned instead.
value
- is the valuesize
- is the number of characters required.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |