2010 FRC Java API


com.sun.squawk.util
Class Tracer

java.lang.Object
  extended by com.sun.squawk.util.Tracer

public final class Tracer
extends Object

The Tracer class encapsulates a set of static methods that are used to emit execution traces to a print stream.

It is intended for usage of this class to be statically conditional. That is, it need not exist in a production deployment. As such, all calls/references to this class should be wrapped in a conditional test of the final static boolean variable Class#TRACING_ENALBED. For example:


     if (Class.TRACING_ENABLED) && Tracer.isTracing("loading", klass.getName()) {
         Tracer.traceln("Loading "+klass.getName());
     }
 

If the value of Class.TRACING_ENABLED was statically determined to be false by javac, then this whole block of code would be omitted from the compiled class.


Method Summary
static void enableFeature(String feature)
          Enable a given feature to be traced.
static PrintStream getPrintStream()
          Gets the print stream to which traces will be written.
static boolean isTracing(String feature)
          Determines whether or not a given feature is being traced.
static boolean isTracing(String feature, String component)
          Determines whether or not a given feature is being traced for a given component.
static void reset()
          Disable all the enabled features and clears the filter (if any).
static void setFilter(String filter)
          Sets the string used to enable/disable the tracer.
static void setPrintStream(PrintStream out)
          Sets the print stream to which traces will be written.
static void trace(String message)
          Output a string to the tracer's print stream.
static void traceln(String message)
          Output a string to the tracer's print stream followed by a newline.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

enableFeature

public static void enableFeature(String feature)
Enable a given feature to be traced.

Parameters:
feature -

getPrintStream

public static PrintStream getPrintStream()
Gets the print stream to which traces will be written.

Returns:
the print stream to which trace output is written

isTracing

public static boolean isTracing(String feature)
Determines whether or not a given feature is being traced.

Parameters:
feature - the feature to be traced
Returns:
true if tracing this feature

isTracing

public static boolean isTracing(String feature,
                                String component)
Determines whether or not a given feature is being traced for a given component.

Parameters:
feature - the feature to be traced
component - the component to be traced
Returns:
true if tracing this feature

reset

public static void reset()
Disable all the enabled features and clears the filter (if any).


setFilter

public static void setFilter(String filter)
Sets the string used to enable/disable the tracer. If filter is null, then filtering is turned off.

Parameters:
filter - the string used to enable/disable the tracer

setPrintStream

public static void setPrintStream(PrintStream out)
Sets the print stream to which traces will be written. This must be done before a call to trace(String) or traceln(String).

Parameters:
out - the print stream to which trace output is written

trace

public static void trace(String message)
Output a string to the tracer's print stream.

Parameters:
message - the message to write

traceln

public static void traceln(String message)
Output a string to the tracer's print stream followed by a newline.

Parameters:
message - the message to write

2010 FRC Java API


Copyright © 2006-2009 Sun Microsystems, Inc. All Rights Reserved.