Class RetryResultLogger


  • public class RetryResultLogger
    extends Object
    Utility class for logging information about errors in RetryResult objects.
    • Constructor Detail

      • RetryResultLogger

        public RetryResultLogger()
    • 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 it RetryResult.failed().
        Type Parameters:
        T - the type held in the result
        Parameters:
        result - the result
        logger - the SLF4J logger to use
        actionDescriptionSupplier - a Supplier 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 result
        logger - the SLF4J logger to use
        actionDescriptionSupplier - a Supplier 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 result
        logger - the SLF4J logger to use
        actionDescription - a Supplier 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 result
        logger - 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 result
        logger - 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 result
        logger - the SLF4J logger to use