eneter.messaging.diagnostic
Class EneterTrace

java.lang.Object
  extended by eneter.messaging.diagnostic.EneterTrace

public class EneterTrace
extends java.lang.Object

Super duper trace. Example showing how to enable tracing of communication errors and warnings to a file:

 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); } } }

Output:
  23:58:54.585 ~  1 --> some.namespace.MyClass.doSomething 
  23:58:54.585 ~  1 <-- some.namespace.MyClass.doSomething [0:0:0 0ms 5.0us]
  
  


Nested Class Summary
static class EneterTrace.EDetailLevel
          Detail level of the trace.
 
Method Summary
static void debug(int skipCallstackFrames, java.lang.String message)
          Traces the debug 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.String errorDetails)
          Traces the error message and details for the error.
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.String details)
          Traces the information message and details.
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 warning(int skipCallstackFrames, 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.String details)
          Traces the warning message and details
static void warning(java.lang.String message, java.lang.Throwable err)
          Traces the warning message.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

entering

public static EneterTrace entering()
Traces entering-leaving the method. The entering information for the method calling this constructor is put to the trace and the measuring of the time starts. In order to trace entering-leaving, the detail level must be set to 'Debug'.


leaving

public static void leaving(EneterTrace trace)
Traces the leaving from the method.

Parameters:
trace - The reference obtained during the entering the method.

info

public static void info(java.lang.String message)
Traces the info message.

Parameters:
message - info message

info

public static void info(java.lang.String message,
                        java.lang.String details)
Traces the information message and details.

Parameters:
message - info message
details - additional details

info

public static void info(java.lang.String message,
                        java.lang.Throwable err)
Traces the info message.

Parameters:
message - info message
err - exception that will be traced

warning

public static void warning(java.lang.String message)
Traces the warning message.

Parameters:
message - warning message

warning

public static void warning(int skipCallstackFrames,
                           java.lang.String message)
Traces the warning message.

Parameters:
skipCallstackFrames - indicates how many fames from the stack shall be ignored when evaluating the position in the stack.
message - warning message

warning

public static void warning(java.lang.String message,
                           java.lang.String details)
Traces the warning message and details

Parameters:
message - warning message
details - additional details

warning

public static void warning(java.lang.String message,
                           java.lang.Throwable err)
Traces the warning message.

Parameters:
message - warning message
err - exception that will be traced

error

public static void error(java.lang.String message)
Traces the error message.

Parameters:
message - error message

error

public static void error(java.lang.String message,
                         java.lang.String errorDetails)
Traces the error message and details for the error.

Parameters:
message - error message
errorDetails - additional details

error

public static void error(java.lang.String message,
                         java.lang.Throwable err)
Traces the error message.

Parameters:
message - error message
err - exception that will be traced

debug

public static void debug(java.lang.String message)
Traces the debug message. To trace debug messages, the detail level must be set to debug.

Parameters:
message - debug message

debug

public static void debug(int skipCallstackFrames,
                         java.lang.String message)
Traces the debug message.

Parameters:
skipCallstackFrames - indicates how many frames shall be skipped when evaluating the callstack.
message - debug message

getTraceLog

public static java.io.PrintStream getTraceLog()
Gets the user defined trace. If the value is set, the trace messages are written to the specified trace. If the value is null, then messages are written only to the debug port.


setTraceLog

public static void setTraceLog(java.io.PrintStream value)
Sets the user defined trace. If the value is set, the trace messages are written to the specified trace. If the value is null, then messages are written only to the debug port.


getDetailLevel

public static EneterTrace.EDetailLevel getDetailLevel()
Gets the detail level of the trace.

Returns:
EDetailLevel enumerator

setDetailLevel

public static void setDetailLevel(EneterTrace.EDetailLevel value)
Sets the detail level of the trace. If the detail level is set to 'Short' then only info, warning and error messages are traced.
If the detail level is set to 'Debug' then all messages are traced.

Parameters:
value -

getNameSpaceFilter

public static java.util.regex.Pattern getNameSpaceFilter()
Gets the regular expression that will be applied to the namespace to filter traced messages.


setNameSpaceFilter

public 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.

Parameters:
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.

The following example shows how to set the filter to trace a certain namespace.
 // 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)");