Class TimerLogger


  • public final class TimerLogger
    extends java.lang.Object
    An utility class that allows automatic logging of the execution time of a method.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static void execAction​(org.apache.logging.log4j.Logger logger, java.lang.String message, TimerLogger.LoggableAction action)
      Executes the given action, while logging the time need for it to complete.
      static void execAction​(org.apache.logging.log4j.Logger logger, org.apache.logging.log4j.Level logLevel, TimeFormat formatter, java.lang.String message, TimerLogger.LoggableAction action)
      Executes the given action, while logging the time need for it to complete.
      static void execAction​(org.apache.logging.log4j.Logger logger, org.apache.logging.log4j.Level logLevel, java.lang.String message, TimerLogger.LoggableAction action)
      Executes the given action, while logging the time need for it to complete.
      static <T> T execSupplier​(org.apache.logging.log4j.Logger logger, java.lang.String message, TimerLogger.LoggableSupplier<T> supplier)
      Executes the given supplier, while logging the time need for it to complete.
      static <T> T execSupplier​(org.apache.logging.log4j.Logger logger, org.apache.logging.log4j.Level logLevel, TimeFormat formatter, java.lang.String message, TimerLogger.LoggableSupplier<T> supplier)
      Executes the given supplier, while logging the time need for it to complete.
      static <T> T execSupplier​(org.apache.logging.log4j.Logger logger, org.apache.logging.log4j.Level logLevel, java.lang.String message, TimerLogger.LoggableSupplier<T> supplier)
      Executes the given supplier, while logging the time need for it to complete.
      • Methods inherited from class java.lang.Object

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

      • execAction

        public static void execAction​(org.apache.logging.log4j.Logger logger,
                                      java.lang.String message,
                                      TimerLogger.LoggableAction action)
        Executes the given action, while logging the time need for it to complete. The log is issued at Level.INFO level, and the elapsed time is formatted up to minutes.
        Parameters:
        logger - the logger to log onto
        message - the message to display
        action - the action to execute
      • execAction

        public static void execAction​(org.apache.logging.log4j.Logger logger,
                                      org.apache.logging.log4j.Level logLevel,
                                      java.lang.String message,
                                      TimerLogger.LoggableAction action)
        Executes the given action, while logging the time need for it to complete. The elapsed time is formatted up to minutes.
        Parameters:
        logger - the logger to log onto
        logLevel - the level to log at
        message - the message to display
        action - the action to execute
      • execAction

        public static void execAction​(org.apache.logging.log4j.Logger logger,
                                      org.apache.logging.log4j.Level logLevel,
                                      TimeFormat formatter,
                                      java.lang.String message,
                                      TimerLogger.LoggableAction action)
        Executes the given action, while logging the time need for it to complete. The elapsed time is formatted up to minutes.
        Parameters:
        logger - the logger to log onto
        logLevel - the level to log at
        formatter - the time format to log
        message - the message to display
        action - the action to execute
      • execSupplier

        public static <T> T execSupplier​(org.apache.logging.log4j.Logger logger,
                                         java.lang.String message,
                                         TimerLogger.LoggableSupplier<T> supplier)
        Executes the given supplier, while logging the time need for it to complete. The log is issued at Level.INFO level, and the elapsed time is formatted up to minutes.
        Type Parameters:
        T - the type of the supplied value
        Parameters:
        logger - the logger to log onto
        message - the message to display
        supplier - the supplier to execute
        Returns:
        the supplied value
      • execSupplier

        public static <T> T execSupplier​(org.apache.logging.log4j.Logger logger,
                                         org.apache.logging.log4j.Level logLevel,
                                         java.lang.String message,
                                         TimerLogger.LoggableSupplier<T> supplier)
        Executes the given supplier, while logging the time need for it to complete. The elapsed time is formatted up to minutes.
        Type Parameters:
        T - the type of the supplied value
        Parameters:
        logger - the logger to log onto
        logLevel - the level to log at
        message - the message to display
        supplier - the supplier to execute
        Returns:
        the supplied value
      • execSupplier

        public static <T> T execSupplier​(org.apache.logging.log4j.Logger logger,
                                         org.apache.logging.log4j.Level logLevel,
                                         TimeFormat formatter,
                                         java.lang.String message,
                                         TimerLogger.LoggableSupplier<T> supplier)
        Executes the given supplier, while logging the time need for it to complete. The elapsed time is formatted up to minutes.
        Type Parameters:
        T - the type of the supplied value
        Parameters:
        logger - the logger to log onto
        logLevel - the level to log at
        formatter - the time format to log
        message - the message to display
        supplier - the supplier to execute
        Returns:
        the supplied value