Package it.unive.lisa.logging
Class TimerLogger
- java.lang.Object
-
- it.unive.lisa.logging.TimerLogger
-
public final class TimerLogger extends java.lang.Object
An utility class that allows automatic logging of the execution time of a method.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
TimerLogger.LoggableAction
ARunnable
executing a function with no arguments a no return value.static interface
TimerLogger.LoggableSupplier<R>
ASupplier
producing one element.
-
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.
-
-
-
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 atLevel.INFO
level, and the elapsed time is formatted up to minutes.- Parameters:
logger
- the logger to log ontomessage
- the message to displayaction
- 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 ontologLevel
- the level to log atmessage
- the message to displayaction
- 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 ontologLevel
- the level to log atformatter
- the time format to logmessage
- the message to displayaction
- 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 atLevel.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 ontomessage
- the message to displaysupplier
- 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 ontologLevel
- the level to log atmessage
- the message to displaysupplier
- 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 ontologLevel
- the level to log atformatter
- the time format to logmessage
- the message to displaysupplier
- the supplier to execute- Returns:
- the supplied value
-
-