Class DebugLogTee<T extends AbstractTracer>

  • Type Parameters:
    T - The actual tracer type
    Direct Known Subclasses:
    FileTracerLogTee

    public abstract class DebugLogTee<T extends AbstractTracer>
    extends AbstractTracer
    An abstract base class which provides the environment to connect additionally to another log system, such as log4j. This class honors the contract of the AbstractTracer base class but does so by wrapping and delegating to another AbstractTracer. Besides two abstract adapt methods must be implemented to route log messages to the desired log system. Note that the wrapped tracer instance must not be a NullTracer. An adapter which is only interested in logging messages and wants to discard the additional tracing information altogether should be derived directly from the NullTracer.
    Author:
    Christof Reichardt
    • Constructor Detail

      • DebugLogTee

        public DebugLogTee​(String name,
                           T tracer)
        Constructor expects the name of the tracer and the to be wrapped Tracer instance.
        Parameters:
        name - the name of the tracer
        tracer - the to be wrapped tracer (must not be a NullTracer instance)
    • Method Detail

      • setAutoflush

        public final void setAutoflush​(boolean autoflush)
        Description copied from class: AbstractTracer
        Used during the configuration. Indicates whether the output stream will be flushed when leaving a method by AbstractTracer.wayout().
        Overrides:
        setAutoflush in class AbstractTracer
        Parameters:
        autoflush - the autoflush to set
      • open

        public void open()
        Description copied from class: AbstractTracer
        Derived classes should provide code that opens the respective output streams.
        Specified by:
        open in class AbstractTracer
      • close

        public void close()
        Description copied from class: AbstractTracer
        Derived classes should provide code that closes the output streams.
        Specified by:
        close in class AbstractTracer
      • initCurrentTracingContext

        public final void initCurrentTracingContext()
        Description copied from class: AbstractTracer
        Initialises the current tracing context by taking the values for debugLevel and online from the configured debug map.
        Overrides:
        initCurrentTracingContext in class AbstractTracer
      • initCurrentTracingContext

        public final void initCurrentTracingContext​(int debugLevel,
                                                    boolean online)
        Description copied from class: AbstractTracer
        Initialises the current tracing context with the given debugLevel and online state.
        Overrides:
        initCurrentTracingContext in class AbstractTracer
        Parameters:
        debugLevel - controls the extent of the output
        online - a value of false delivers no output of the current thread at all whereas a value of true delivers output controlled by debugLevel
      • adapt

        protected abstract void adapt​(LogLevel logLevel,
                                      String message,
                                      Class<?> clazz)
        Derived classes should provide code which routes the given message with the denoted logLevel and class to the desired log system.
        Parameters:
        logLevel - the to be translated LogLevel
        message - the actual message
        clazz - the class context of the message
      • adapt

        protected abstract void adapt​(LogLevel logLevel,
                                      Throwable throwable,
                                      Class<?> clazz)
        Derived classes should provide code which routes the given throwable with the denoted logLevel and class to the desired log system.
        Parameters:
        logLevel - the to be translated LogLevel
        throwable - references the to be logged info
        clazz - the class context of the message
      • entry

        public TraceMethod entry​(String returnType,
                                 Class<?> clazz,
                                 String methodSignature)
        Description copied from class: AbstractTracer
        Indicates an entering of a method which belongs to a class. If a TracingContext exists for the current thread a TraceMethod object will be created and thereupon pushed onto the stack of a ThreadMap.
        Overrides:
        entry in class AbstractTracer
        Parameters:
        returnType - the return type of the method as string representation
        clazz - the class to which that method belong
        methodSignature - the remaining method signature (without return type) inclusive parameter as string representation
        Returns:
        the TraceMethod which has been put onto the stack - a mere data object for internal use primarily. May be null.
      • entry

        public TraceMethod entry​(String returnType,
                                 Object object,
                                 String methodSignature)
        Description copied from class: AbstractTracer
        Indicates an entering of a method which belongs to an object. If a TracingContext exists for the current thread a TraceMethod object will be created and thereupon pushed onto the stack of a ThreadMap.
        Overrides:
        entry in class AbstractTracer
        Parameters:
        returnType - the return type of the method as string representation
        object - the object that owns the method
        methodSignature - the remaining method signature (without return type) inclusive parameter as string representation
        Returns:
        the TraceMethod which has been put onto the stack - a mere data object for internal use primarily. May be null.
      • entry

        @Deprecated
        public TraceMethod entry​(String methodSignature)
        Deprecated.
        Description copied from class: AbstractTracer
        Indicates an entering of a method.
        Overrides:
        entry in class AbstractTracer
        Parameters:
        methodSignature - the signature of the method as string representation
        Returns:
        the TraceMethod which has been put onto the stack - a mere data object for internal use primarily. May be null.
      • logMessage

        public final void logMessage​(LogLevel logLevel,
                                     String message,
                                     Class<?> clazz,
                                     String methodName)
        Description copied from class: AbstractTracer
        Logs a message with the given logLevel and the originating class.
        Overrides:
        logMessage in class AbstractTracer
        Parameters:
        logLevel - one of the predefined levels INFO, WARNING, ERROR, FATAL and SEVERE
        message - the to be logged message
        clazz - the originating class
        methodName - the originating method
      • logException

        public final void logException​(LogLevel logLevel,
                                       Throwable throwable,
                                       Class<?> clazz,
                                       String methodName)
        Description copied from class: AbstractTracer
        Logs an exception with the given logLevel and the originating class.
        Overrides:
        logException in class AbstractTracer
        Parameters:
        logLevel - one of the predefined levels INFO, WARNING, ERROR, FATAL and SEVERE
        throwable - the to be logged throwable
        clazz - the originating class
        methodName - the name of the relevant method
      • wayout

        public TraceMethod wayout()
        Description copied from class: AbstractTracer
        Indicates the exiting of a method.
        Overrides:
        wayout in class AbstractTracer
        Returns:
        the TraceMethod which has been popped from the stack - a mere data object for internal use primarily. May be null.