Class ContextTracer

java.lang.Object
org.eclipse.net4j.util.om.trace.ContextTracer
Direct Known Subclasses:
PerfTracer

public class ContextTracer extends Object
Encapsulates a tracing context and delegates trace calls to a bundle tracer.
Author:
Eike Stepper
See Also:
  • Constructor Details

    • ContextTracer

      public ContextTracer(OMTracer delegate, Class<?> context)
  • Method Details

    • getContext

      public Class<?> getContext()
      Since:
      3.2
    • getBundle

      public OMBundle getBundle()
    • getFullName

      public String getFullName()
    • getName

      public String getName()
    • getDelegate

      public OMTracer getDelegate()
    • getParent

      public OMTracer getParent()
    • isEnabled

      public boolean isEnabled()
    • setEnabled

      public void setEnabled(boolean enabled)
    • ifEnabled

      public boolean ifEnabled(Consumer<ContextTracer> consumer)
      Provides zero-cost tracing in combination with the assert keyword.

      Example:

         ContextTracer tracer = ...;
      
         assert tracer.ifEnabled(t -> t.format("User %0 logged on", user));
       
      Returns:
      Always true
      Since:
      3.16
    • format

      public void format(String pattern, Object... args)
    • format

      public void format(String pattern, Throwable t, Object... args)
    • trace

      public void trace(String msg, Throwable t)
    • trace

      public void trace(String msg)
    • trace

      public void trace(Throwable t)
    • toString

      public String toString()
      Overrides:
      toString in class Object