Package com.yahoo.messagebus
Class Trace
java.lang.Object
com.yahoo.messagebus.Trace
A Trace object contains ad-hoc string notes organized in a strict-loose tree. A Trace object consists of a trace
level indicating which trace notes should be included and a TraceTree object containing the tree structure and
collecting the trace information. Tracing is used to collect debug information about a Routable traveling through the
system. The trace level is in the range [0,9]. 0 means no tracing, and 9 means all tracing is enabled. A client that
has the ability to trace information will have a predefined level attached to that information. If the level on the
information is lower or equal to the level set in the Trace object, the information will be traced.
- Author:
- Simon Thoresen Hult
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionclear()
Remove all trace information and set the trace level to 0.int
getLevel()
Returns the trace level.getRoot()
Returns the root of the trace tree.setLevel
(int level) Set the trace level.boolean
shouldTrace
(int level) Check if information with the given level should be traced.Swap the internals of this with another.toString()
boolean
Add the given note to the trace information if tracing is enabled for the given level.boolean
Add the given note to the trace information if tracing is enabled for the given level.
-
Constructor Details
-
Trace
public Trace()Create an empty trace with level set to 0 (no tracing) -
Trace
public Trace(int level) Create an empty trace with given level.- Parameters:
level
- Level to set.
-
-
Method Details
-
clear
Remove all trace information and set the trace level to 0.- Returns:
- This, to allow chaining.
-
swap
Swap the internals of this with another.- Parameters:
other
- The trace to swap internals with.- Returns:
- This, to allow chaining.
-
setLevel
Set the trace level. 0 means no tracing, 9 means enable all tracing.- Parameters:
level
- The level to set.- Returns:
- This, to allow chaining.
-
getLevel
public int getLevel()Returns the trace level.- Returns:
- The trace level.
-
shouldTrace
public boolean shouldTrace(int level) Check if information with the given level should be traced. This method is added to allow clients to check if something should be traced before spending time building up the trace information itself.- Parameters:
level
- The trace level to test.- Returns:
- True if tracing is enabled for the given level, false otherwise.
-
trace
Add the given note to the trace information if tracing is enabled for the given level.- Parameters:
level
- The trace level of the note.note
- The note to add.- Returns:
- True if the note was added to the trace information, false otherwise.
-
trace
Add the given note to the trace information if tracing is enabled for the given level. If the addTime parameter is true, then the note is prefixed with the current time. This is the default behaviour when ommiting this parameter.- Parameters:
level
- The trace level of the note.note
- The note to add.addTime
- Whether or not to prefix note with a timestamp.- Returns:
- True if the note was added to the trace information, false otherwise.
-
getRoot
Returns the root of the trace tree.- Returns:
- The root.
-
toString
-