Class LoggerHelpers


  • public final class LoggerHelpers
    extends java.lang.Object
    Extension methods for Logger class.
    • Constructor Summary

      Constructors 
      Constructor Description
      LoggerHelpers()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.Object exceptionSummary​(org.slf4j.Logger log, java.lang.Throwable e)
      Returns either the given Throwable or its message, depending on the current logging context.
      static long traceEnter​(org.slf4j.Logger log, java.lang.String method, java.lang.Object... args)
      Traces the fact that a method entry has occurred.
      static long traceEnterWithContext​(org.slf4j.Logger log, java.lang.String context, java.lang.String method, java.lang.Object... args)
      Traces the fact that a method entry has occurred.
      static void traceLeave​(org.slf4j.Logger log, java.lang.String method, long traceEnterId, java.lang.Object... args)
      Traces the fact that a method has exited normally.
      static void traceLeave​(org.slf4j.Logger log, java.lang.String context, java.lang.String method, long traceEnterId, java.lang.Object... args)
      Traces the fact that a method has exited normally.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • LoggerHelpers

        public LoggerHelpers()
    • Method Detail

      • traceEnter

        public static long traceEnter​(org.slf4j.Logger log,
                                      java.lang.String method,
                                      java.lang.Object... args)
        Traces the fact that a method entry has occurred.
        Parameters:
        log - The Logger to log to.
        method - The name of the method.
        args - The arguments to the method.
        Returns:
        A generated identifier that can be used to correlate this traceEnter with its corresponding traceLeave. This is usually generated from the current System time, and when used with traceLeave it can be used to log elapsed call times.
      • traceEnterWithContext

        public static long traceEnterWithContext​(org.slf4j.Logger log,
                                                 java.lang.String context,
                                                 java.lang.String method,
                                                 java.lang.Object... args)
        Traces the fact that a method entry has occurred.
        Parameters:
        log - The Logger to log to.
        context - Identifying context for the operation. For example, this can be used to differentiate between different instances of the same object.
        method - The name of the method.
        args - The arguments to the method.
        Returns:
        A generated identifier that can be used to correlate this traceEnter with its corresponding traceLeave. This is usually generated from the current System time, and when used with traceLeave it can be used to log elapsed call times.
      • traceLeave

        public static void traceLeave​(org.slf4j.Logger log,
                                      java.lang.String method,
                                      long traceEnterId,
                                      java.lang.Object... args)
        Traces the fact that a method has exited normally.
        Parameters:
        log - The Logger to log to.
        method - The name of the method.
        traceEnterId - The correlation Id obtained from a traceEnter call.
        args - Additional arguments to log.
      • traceLeave

        public static void traceLeave​(org.slf4j.Logger log,
                                      java.lang.String context,
                                      java.lang.String method,
                                      long traceEnterId,
                                      java.lang.Object... args)
        Traces the fact that a method has exited normally.
        Parameters:
        log - The Logger to log to.
        context - Identifying context for the operation. For example, this can be used to differentiate between different instances of the same object.
        method - The name of the method.
        traceEnterId - The correlation Id obtained from a traceEnter call.
        args - Additional arguments to log.
      • exceptionSummary

        public static java.lang.Object exceptionSummary​(org.slf4j.Logger log,
                                                        java.lang.Throwable e)
        Returns either the given Throwable or its message, depending on the current logging context.
        Parameters:
        log - The Logger to query.
        e - The Throwable to return or process.
        Returns:
        The given Throwable, if Logger.isDebugEnabled() is true for log, or Throwable.toString() otherwise (which should output only the name of the exception).