Package org.kiwiproject.retry
Class RetryResultLogger
- java.lang.Object
-
- org.kiwiproject.retry.RetryResultLogger
-
public class RetryResultLogger extends Object
Utility class for logging information about errors inRetryResult
objects.
-
-
Constructor Summary
Constructors Constructor Description RetryResultLogger()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static <T> void
logAllExceptions(RetryResult<T> result, org.slf4j.Logger logger)
Log all exceptions contained in the result using the given logger.static <T> void
logExceptionTypesAndLast(RetryResult<T> result, org.slf4j.Logger logger)
Log the unique error types and the last exception contained in the result using the given logger.static <T> void
logLastException(RetryResult<T> result, org.slf4j.Logger logger)
Log only the last exception contained in the result using the given logger.static <T> void
logSummary(RetryResult<T> result, org.slf4j.Logger logger, String actionDescription)
Logs a high-level summary of the result.static <T> void
logSummaryIfFailed(RetryResult<T> result, org.slf4j.Logger logger, Supplier<String> actionDescriptionSupplier)
Logs a summary of the given result only if itRetryResult.failed()
.static <T> void
logSummaryIfHasErrorsOrMultipleAttempts(RetryResult<T> result, org.slf4j.Logger logger, Supplier<String> actionDescriptionSupplier)
Logs a summary of the given result only if it has any errors or more than one attempt was made.
-
-
-
Method Detail
-
logSummaryIfFailed
public static <T> void logSummaryIfFailed(RetryResult<T> result, org.slf4j.Logger logger, Supplier<String> actionDescriptionSupplier)
Logs a summary of the given result only if itRetryResult.failed()
.- Type Parameters:
T
- the type held in the result- Parameters:
result
- the resultlogger
- the SLF4J logger to useactionDescriptionSupplier
- aSupplier
that provides a description of the action that was attempted for example "Create new order #12345" or "Update order #456"- See Also:
logSummary(RetryResult, Logger, String)
-
logSummaryIfHasErrorsOrMultipleAttempts
public static <T> void logSummaryIfHasErrorsOrMultipleAttempts(RetryResult<T> result, org.slf4j.Logger logger, Supplier<String> actionDescriptionSupplier)
Logs a summary of the given result only if it has any errors or more than one attempt was made.- Type Parameters:
T
- the type held in the result- Parameters:
result
- the resultlogger
- the SLF4J logger to useactionDescriptionSupplier
- aSupplier
that provides a description of the action that was attempted for example "Create new order #12345" or "Update order #456"
-
logSummary
public static <T> void logSummary(RetryResult<T> result, org.slf4j.Logger logger, String actionDescription)
Logs a high-level summary of the result. The log level is dependent on whether the result was successful or not, and whether there were any errors (e.g. a result was successful but took more than one attempt).The log levels are:
Result failed: ERROR
Result succeeded with errors: WARN
Result succeeded with no errors: DEBUG
- Type Parameters:
T
- the type held in the result- Parameters:
result
- the resultlogger
- the SLF4J logger to useactionDescription
- aSupplier
that provides a description of the action that was attempted for example "Create new order #12345" or "Update order #456"
-
logAllExceptions
public static <T> void logAllExceptions(RetryResult<T> result, org.slf4j.Logger logger)
Log all exceptions contained in the result using the given logger.- Type Parameters:
T
- the type held in the result- Parameters:
result
- the resultlogger
- the SLF4J logger to use
-
logLastException
public static <T> void logLastException(RetryResult<T> result, org.slf4j.Logger logger)
Log only the last exception contained in the result using the given logger.- Type Parameters:
T
- the type held in the result- Parameters:
result
- the resultlogger
- the SLF4J logger to use
-
logExceptionTypesAndLast
public static <T> void logExceptionTypesAndLast(RetryResult<T> result, org.slf4j.Logger logger)
Log the unique error types and the last exception contained in the result using the given logger.- Type Parameters:
T
- the type held in the result- Parameters:
result
- the resultlogger
- the SLF4J logger to use
-
-