Class LoggerDisabler

java.lang.Object
edu.wpi.first.epilogue.logging.errors.LoggerDisabler
All Implemented Interfaces:
ErrorHandler

public class LoggerDisabler extends Object implements ErrorHandler
An error handler that disables loggers after too many exceptions are raised. Useful when playing in matches, where data logging is less important than reliable control. Setting the threshold to ≤0 will cause any logger that encounters an exception whilst logging to immediately be disabled. Setting to higher values means your program is more tolerant of errors, but takes longer to disable, and therefore may have more sets of partial or incomplete data and may have more CPU overhead due to the cost of throwing exceptions.
  • Constructor Details

    • LoggerDisabler

      public LoggerDisabler(int threshold)
      Creates a new logger-disabling error handler.
      Parameters:
      threshold - how many errors any one logger is allowed to encounter before it is disabled.
  • Method Details

    • forLimit

      public static LoggerDisabler forLimit(int threshold)
      Creates a disabler that kicks in after a logger raises more than threshold exceptions.
      Parameters:
      threshold - the threshold value for the maximum number of exceptions loggers are permitted to encounter before they are disabled
      Returns:
      the disabler
    • handle

      public void handle(Throwable exception, ClassSpecificLogger<?> logger)
      Description copied from interface: ErrorHandler
      Handles an exception that arose while logging.
      Specified by:
      handle in interface ErrorHandler
      Parameters:
      exception - the exception that occurred
      logger - the logger that was being processed that caused the error to occur
    • reset

      public void reset()
      Resets all error counts and reenables all loggers.