|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.lsst.ccs.utilities.tracers.Tracer
public class Tracer
Utility to add traces to a code.
Though it is a hack on assertions this can be used that way
import static org.lsst.ccs.utilities.tracers.Tracer.* ;
....
public void myMethod(int arg) {
assert trace("myMethod called with" +arg) ;
// code
}
public void anotherMethod(String arg) {
assert stackTrace() ;
}
A developper can also use home-grown filters
import static org.lsst.ccs.utilities.tracers.Tracer.* ;
import org.lsst.ccs.mypackage.MyEnum ;
....
public void myMethod(int arg) {
assert trace(MyEnum.DOING_THIS, "myMethod called with" +arg) ;
// code
}
public void anotherMethod(String arg) {
assert stackTrace(MyEnum.DOING_THAT) ;
}
then if System property org.lsst.ccs.traces is set
the traces can be produced or not. Example of option
-Dorg.lsst.ccs.traces=DOING_THIS,DOING_THAT
By default the strings are printed to System.out but ths can be changed.
If you want to delegate the reporting to another code (such as a Logger)
write a code implementing Tracer.Strategy
and deploy it using the ServiceLoader (or put the canonical
className as value for property org.lsst.ccs.traceReporter).
| Nested Class Summary | |
|---|---|
static class |
Tracer.MultiReporter
Convenience class to create a code that reports to many report "handlers". |
static interface |
Tracer.Strategy
defines the behaviour of a tracer. |
| Field Summary | |
|---|---|
protected static String[] |
keys
|
static Tracer.Strategy |
reporter
|
| Constructor Summary | |
|---|---|
Tracer()
|
|
| Method Summary | ||
|---|---|---|
static Tracer.Strategy |
getReporter()
|
|
static void |
setReporter(Tracer.Strategy reporter)
|
|
static boolean |
stackTrace()
reports a complete stack trace of the current code execution. |
|
protected static void |
stackTrace(int levelOut)
reports part a stacktrace starting at index levelOut |
|
static boolean |
stackTrace(String filter)
reports a complete stack trace of the current code execution only if the filter string is part of the org.lsst.ccs.traces property. |
|
static
|
stackTrace(T enumElement)
reports a complete stack trace of the current code execution only if the filter enum constant is cited in the org.lsst.ccs.traces property. |
|
static boolean |
trace(String traceString)
utility method to fire a trace. |
|
static boolean |
trace(String filter,
String traceString)
reports a trace only if the filter string is part of the org.lsst.ccs.traces property. |
|
static
|
trace(T enumElement,
String traceString)
uses an enum constant to filter the message passed to the tracer. |
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static Tracer.Strategy reporter
protected static String[] keys
| Constructor Detail |
|---|
public Tracer()
| Method Detail |
|---|
public static void setReporter(Tracer.Strategy reporter)
public static Tracer.Strategy getReporter()
public static boolean trace(String traceString)
traceString - will always be transmitted to code for reporting the trace
public static boolean trace(String filter,
String traceString)
filter - traceString -
public static <T extends Enum> boolean trace(T enumElement,
String traceString)
T - enumElement - traceString -
public static boolean stackTrace()
public static boolean stackTrace(String filter)
filter -
public static <T extends Enum> boolean stackTrace(T enumElement)
T - enumElement -
protected static void stackTrace(int levelOut)
levelOut -
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||