public class EneterTrace
extends java.lang.Object
EneterTrace.setDetailLevel(EneterTrace.EDetailLevel.Short); EneterTrace.setTraceLog(new PrintStream("D:\\Trace.txt"));Example showing how to enable tracing of detailed communication sequence to a file:
EneterTrace.setDetailLevel(EneterTrace.EDetailLevel.Debug); EneterTrace.setTraceLog(new PrintStream("D:\\Trace.txt"));Example showing how you can trace entering/leaving methods:
class MyClass { ...
void doSomething() { EneterTrace aTrace = EneterTrace.entering(); try { ... } finally { EneterTrace.leaving(aTrace); } } }
23:58:54.585 ~ 1 --> some.namespace.MyClass.doSomething
23:58:54.585 ~ 1 <-- some.namespace.MyClass.doSomething [0:0:0 0ms 5.0us]
Modifier and Type | Class and Description |
---|---|
static class |
EneterTrace.EDetailLevel
Detail level of the trace.
|
Modifier and Type | Method and Description |
---|---|
static void |
debug(int callstackIndex,
java.lang.String message)
Traces the warning message.
|
static void |
debug(java.lang.String message)
Traces the debug message.
|
static EneterTrace |
entering()
Traces entering-leaving the method.
|
static void |
error(java.lang.String message)
Traces the error message.
|
static void |
error(java.lang.String message,
java.lang.Throwable err)
Traces the error message.
|
static EneterTrace.EDetailLevel |
getDetailLevel()
Gets the detail level of the trace.
|
static java.util.regex.Pattern |
getNameSpaceFilter()
Gets the regular expression that will be applied to the namespace to filter traced messages.
|
static java.io.PrintStream |
getTraceLog()
Gets the user defined trace.
|
static void |
info(java.lang.String message)
Traces the info message.
|
static void |
info(java.lang.String message,
java.lang.Throwable err)
Traces the info message.
|
static void |
leaving(EneterTrace trace)
Traces the leaving from the method.
|
static void |
setDetailLevel(EneterTrace.EDetailLevel value)
Sets the detail level of the trace.
|
static void |
setNameSpaceFilter(java.util.regex.Pattern value)
Sets or gets the regular expression that will be applied to the namespace to filter traced messages.
|
static void |
setTraceLog(java.io.PrintStream value)
Sets the user defined trace.
|
static void |
startProfiler()
Starts the profiler measurement.
|
static void |
stopProfiler()
Stops the profiler measurement and writes results to the trace.
|
static void |
warning(int callstackIndex,
java.lang.String message)
Traces the warning message.
|
static void |
warning(java.lang.String message)
Traces the warning message.
|
static void |
warning(java.lang.String message,
java.lang.Throwable err)
Traces the warning message.
|
public static EneterTrace entering()
public static void leaving(EneterTrace trace)
trace
- The reference obtained during the entering the method.public static void info(java.lang.String message)
message
- info messagepublic static void info(java.lang.String message, java.lang.Throwable err)
message
- info messageerr
- exception that will be tracedpublic static void warning(java.lang.String message)
message
- warning messagepublic static void warning(int callstackIndex, java.lang.String message)
callstackIndex
- message
- warning messagepublic static void warning(java.lang.String message, java.lang.Throwable err)
message
- warning messageerr
- exception that will be tracedpublic static void error(java.lang.String message)
message
- error messagepublic static void error(java.lang.String message, java.lang.Throwable err)
message
- error messageerr
- exception that will be tracedpublic static void debug(int callstackIndex, java.lang.String message)
callstackIndex
- message
- warning messagepublic static void debug(java.lang.String message)
message
- debug messagepublic static void startProfiler()
public static void stopProfiler()
public static java.io.PrintStream getTraceLog()
public static void setTraceLog(java.io.PrintStream value)
public static EneterTrace.EDetailLevel getDetailLevel()
public static void setDetailLevel(EneterTrace.EDetailLevel value)
value
- public static java.util.regex.Pattern getNameSpaceFilter()
public static void setNameSpaceFilter(java.util.regex.Pattern value)
value
- If the namespace matches with the regular expression, the message will be traced.
If the filter is set to null, then the filter is not used and all messages will be traced.
// Set the debug detailed level.
EneterTrace.DetailLevel = EneterTrace.EDetailLevel.Debug;
// Examples:
// Traces all name spaces starting with 'My.NameSpace'.
EneterTrace.NameSpaceFilter = Pattern.compile("^My\.NameSpace");
// Traces exactly the name space 'My.NameSpace'.
EneterTrace.NameSpaceFilter = Pattern.compile("^My\.NameSpace$");
// Traces name spaces starting with 'Calc.Methods' or 'App.Utilities'.
EneterTrace.NameSpaceFilter = Pattern.compile("^Calc\.Methods|^App\.Utilities");
// Traces all name spaces except namespaces starting with 'Eneter'.
EneterTrace.NameSpaceFilter = Pattern.compile("^(?!\bEneter\b)");