Class ExecutionTimeLogger


  • public class ExecutionTimeLogger
    extends java.lang.Object
    Logs the execution time of the passed supplier.
    Since:
    2.0.0
    Author:
    Oliver Libutzki <[email protected]>
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> T logExecutionTime​(org.apache.logging.log4j.Logger logger, java.lang.String logPrefix, java.util.function.Supplier<? extends T> supplier)
      Logs the execution time of the passed supplier.
      static <T> T logExecutionTime​(org.apache.logging.log4j.Logger logger, java.util.function.Supplier<java.lang.String> logPrefix, java.util.function.Supplier<? extends T> supplier)
      Logs the execution time of the passed supplier.
      • Methods inherited from class java.lang.Object

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

      • ExecutionTimeLogger

        public ExecutionTimeLogger()
    • Method Detail

      • logExecutionTime

        public static <T> T logExecutionTime​(org.apache.logging.log4j.Logger logger,
                                             java.util.function.Supplier<java.lang.String> logPrefix,
                                             java.util.function.Supplier<? extends T> supplier)
        Logs the execution time of the passed supplier.
        Type Parameters:
        T - return type
        Parameters:
        logger - the logger which should be used
        logPrefix - log prefix supplier
        supplier - supplier which holds the code which's execution time should be measured and logged
        Returns:
        The return value of the given supplier
        Since:
        2.0.0
      • logExecutionTime

        public static <T> T logExecutionTime​(org.apache.logging.log4j.Logger logger,
                                             java.lang.String logPrefix,
                                             java.util.function.Supplier<? extends T> supplier)
        Logs the execution time of the passed supplier.
        Type Parameters:
        T - return type
        Parameters:
        logger - the logger which should be used
        logPrefix - log prefix
        supplier - supplier which holds the code which's execution time should be measured and logged
        Returns:
        The return value of the given supplier
        Since:
        2.0.0