Class Tracer
- java.lang.Object
-
- ej.trace.Tracer
-
public class Tracer extends Object
ATracerobject is used to trace events for debug or monitoring.Tracerare named and can produce a limited number of different event types.The following example uses a
Tracerobject to trace the execution of a method:static final int EVT_FOO = 0; Trace myTracer = new Tracer("MyTracer", 1); int foo(int x, int y) { myTracer.recordEvent(EVT_FOO, x, y); ... myTracer.recordEventEnd(EVT_FOO, z); return z; }
-
-
Field Summary
Fields Modifier and Type Field Description static StringTRACE_ENABLED_CONSTANT_PROPERTYThe value of this boolean constant property istruewhen the traces are enabled in the system andfalseotherwise (seeConstants).
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description intgetGroupID()Gets the group identifier.static booleanisTraceStarted()Tests whether the trace system is started or not.voidrecordEvent(int eventId)Record an event for thisTracer.voidrecordEvent(int eventId, int value1)Record an event for thisTracer.voidrecordEvent(int eventId, int value1, int value2)Record an event for thisTracer.voidrecordEvent(int eventId, int value1, int value2, int value3)Record an event for thisTracer.voidrecordEvent(int eventId, int value1, int value2, int value3, int value4)Record an event for thisTracer.voidrecordEvent(int eventId, int value1, int value2, int value3, int value4, int value5)Record an event for thisTracer.voidrecordEvent(int eventId, int value1, int value2, int value3, int value4, int value5, int value6)Record an event for thisTracer.voidrecordEvent(int eventId, int value1, int value2, int value3, int value4, int value5, int value6, int value7)Record an event for thisTracer.voidrecordEvent(int eventId, int value1, int value2, int value3, int value4, int value5, int value6, int value7, int value8)Record an event for thisTracer.voidrecordEvent(int eventId, int value1, int value2, int value3, int value4, int value5, int value6, int value7, int value8, int value9)Record an event for thisTracer.voidrecordEvent(int eventId, int value1, int value2, int value3, int value4, int value5, int value6, int value7, int value8, int value9, int value10)Record an event for thisTracer.voidrecordEventEnd(int eventId)Record the end of the execution of an event for thisTracer.voidrecordEventEnd(int eventId, int value1)Record the end of the execution of an event for thisTracer.static voidstartTrace()Starts to record the events.static voidstopTrace()Stops to record the events.
-
-
-
Field Detail
-
TRACE_ENABLED_CONSTANT_PROPERTY
public static final String TRACE_ENABLED_CONSTANT_PROPERTY
The value of this boolean constant property istruewhen the traces are enabled in the system andfalseotherwise (seeConstants).It can be used to prevent unnecessary code to be embedded and executed when the traces are disabled:
if (Constants.getBoolean(Tracer.TRACE_ENABLED_CONSTANT_PROPERTY)) { int myEventValue = getMyEventValue(); mytracer.recordEvent(myEvent, myEventValue); }- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Tracer
public Tracer(String name, int nbEventTypes) throws InternalError
Creates a new tracer with the given name. The createdTracerdefinesnbEventTypestypes of events. The event IDs available for this group are from 0 tonbEventTypes-1.- Parameters:
name- name that identifies the group. Must not benull.nbEventTypes- maximum number of event types available for the group.- Throws:
InternalError- if the tracer cannot be created.
-
-
Method Detail
-
startTrace
public static void startTrace()
Starts to record the events.By default, the trace system is stopped.
-
stopTrace
public static void stopTrace()
Stops to record the events. When the record system is stopped, any call to therecordEvent(int)methods will not record any events.By default, the trace system is stopped.
-
isTraceStarted
public static boolean isTraceStarted()
Tests whether the trace system is started or not.- Returns:
trueif the trace system is started,falseotherwise.
-
getGroupID
public int getGroupID()
Gets the group identifier. This identifier is unique for eachTracerinstance.- Returns:
- the group unique identifier.
-
recordEvent
public void recordEvent(int eventId)
Record an event for thisTracer. The given event ID must be valid for thisTracer(i.e. between 0 andnbEventTypes-1 included wherenbEventTypesis the value given to theTracer(String, int)constructor).The record is done only if the trace system is started (see
).startTrace()- Parameters:
eventId- ID of the event.
-
recordEvent
public void recordEvent(int eventId, int value1)Record an event for thisTracer. The given event ID must be valid for thisTracer(i.e. between 0 andnbEventTypes-1 included wherenbEventTypesis the value given to theTracer(String, int)constructor).The record is done only if the trace system is started (see
).startTrace()- Parameters:
eventId- ID of the event.value1- custom value for the event.
-
recordEvent
public void recordEvent(int eventId, int value1, int value2)Record an event for thisTracer. The given event ID must be valid for thisTracer(i.e. between 0 andnbEventTypes-1 included wherenbEventTypesis the value given to theTracer(String, int)constructor).The record is done only if the trace system is started (see
).startTrace()- Parameters:
eventId- ID of the event.value1- custom value for the event.value2- custom value for the event.
-
recordEvent
public void recordEvent(int eventId, int value1, int value2, int value3)Record an event for thisTracer. The given event ID must be valid for thisTracer(i.e. between 0 andnbEventTypes-1 included wherenbEventTypesis the value given to theTracer(String, int)constructor).The record is done only if the trace system is started (see
).startTrace()- Parameters:
eventId- ID of the event.value1- custom value for the event.value2- custom value for the event.value3- custom value for the event.
-
recordEvent
public void recordEvent(int eventId, int value1, int value2, int value3, int value4)Record an event for thisTracer. The given event ID must be valid for thisTracer(i.e. between 0 andnbEventTypes-1 included wherenbEventTypesis the value given to theTracer(String, int)constructor).The record is done only if the trace system is started (see
).startTrace()- Parameters:
eventId- ID of the event.value1- custom value for the event.value2- custom value for the event.value3- custom value for the event.value4- custom value for the event.
-
recordEvent
public void recordEvent(int eventId, int value1, int value2, int value3, int value4, int value5)Record an event for thisTracer. The given event ID must be valid for thisTracer(i.e. between 0 andnbEventTypes-1 included wherenbEventTypesis the value given to theTracer(String, int)constructor).The record is done only if the trace system is started (see
).startTrace()- Parameters:
eventId- ID of the event.value1- custom value for the event.value2- custom value for the event.value3- custom value for the event.value4- custom value for the event.value5- custom value for the event.
-
recordEvent
public void recordEvent(int eventId, int value1, int value2, int value3, int value4, int value5, int value6)Record an event for thisTracer. The given event ID must be valid for thisTracer(i.e. between 0 andnbEventTypes-1 included wherenbEventTypesis the value given to theTracer(String, int)constructor).The record is done only if the trace system is started (see
).startTrace()- Parameters:
eventId- ID of the event.value1- custom value for the event.value2- custom value for the event.value3- custom value for the event.value4- custom value for the event.value5- custom value for the event.value6- custom value for the event.
-
recordEvent
public void recordEvent(int eventId, int value1, int value2, int value3, int value4, int value5, int value6, int value7)Record an event for thisTracer. The given event ID must be valid for thisTracer(i.e. between 0 andnbEventTypes-1 included wherenbEventTypesis the value given to theTracer(String, int)constructor).The record is done only if the trace system is started (see
).startTrace()- Parameters:
eventId- ID of the event.value1- custom value for the event.value2- custom value for the event.value3- custom value for the event.value4- custom value for the event.value5- custom value for the event.value6- custom value for the event.value7- custom value for the event.
-
recordEvent
public void recordEvent(int eventId, int value1, int value2, int value3, int value4, int value5, int value6, int value7, int value8)Record an event for thisTracer. The given event ID must be valid for thisTracer(i.e. between 0 andnbEventTypes-1 included wherenbEventTypesis the value given to theTracer(String, int)constructor).The record is done only if the trace system is started (see
).startTrace()- Parameters:
eventId- ID of the event.value1- custom value for the event.value2- custom value for the event.value3- custom value for the event.value4- custom value for the event.value5- custom value for the event.value6- custom value for the event.value7- custom value for the event.value8- custom value for the event.
-
recordEvent
public void recordEvent(int eventId, int value1, int value2, int value3, int value4, int value5, int value6, int value7, int value8, int value9)Record an event for thisTracer. The given event ID must be valid for thisTracer(i.e. between 0 andnbEventTypes-1 included wherenbEventTypesis the value given to theTracer(String, int)constructor).The record is done only if the trace system is started (see
).startTrace()- Parameters:
eventId- ID of the event.value1- custom value for the event.value2- custom value for the event.value3- custom value for the event.value4- custom value for the event.value5- custom value for the event.value6- custom value for the event.value7- custom value for the event.value8- custom value for the event.value9- custom value for the event.
-
recordEvent
public void recordEvent(int eventId, int value1, int value2, int value3, int value4, int value5, int value6, int value7, int value8, int value9, int value10)Record an event for thisTracer. The given event ID must be valid for thisTracer(i.e. between 0 andnbEventTypes-1 included wherenbEventTypesis the value given to theTracer(String, int)constructor).The record is done only if the trace system is started (see
).startTrace()- Parameters:
eventId- ID of the event.value1- custom value for the event.value2- custom value for the event.value3- custom value for the event.value4- custom value for the event.value5- custom value for the event.value6- custom value for the event.value7- custom value for the event.value8- custom value for the event.value9- custom value for the event.value10- custom value for the event.
-
recordEventEnd
public void recordEventEnd(int eventId)
Record the end of the execution of an event for thisTracer. Call this method to trace the duration of an event previously record with one of therecordEvent(int)methods. This method should not be called for event that has no duration.For example, if you want to trace the execution of a method, you can call
recordEvent(int)at the beginning of the function andrecordEventEnd(int)at the end of the function.The record is done only if the trace system is started (see
startTrace()).- Parameters:
eventId- ID of the event.
-
recordEventEnd
public void recordEventEnd(int eventId, int value1)Record the end of the execution of an event for thisTracer. Call this method to trace the duration of an event previously record with one of therecordEvent(int)methods. This method should not be called for event that has no duration.For example, if you want to trace the execution of a method, you can call
recordEvent(int)at the beginning of the function andrecordEventEnd(int, int)at the end of the function.The record is done only if the trace system is started (see
startTrace()).- Parameters:
eventId- ID of the event.value1- custom value for the event end.
-
-