Class LoggerDisabler
java.lang.Object
edu.wpi.first.epilogue.logging.errors.LoggerDisabler
- All Implemented Interfaces:
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 Summary
-
Method Summary
Modifier and TypeMethodDescriptionstatic LoggerDisabler
forLimit
(int threshold) Creates a disabler that kicks in after a logger raises more thanthreshold
exceptions.void
handle
(Throwable exception, ClassSpecificLogger<?> logger) Handles an exception that arose while logging.void
reset()
Resets all error counts and reenables all loggers.
-
Constructor Details
-
LoggerDisabler
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
Creates a disabler that kicks in after a logger raises more thanthreshold
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
Description copied from interface:ErrorHandler
Handles an exception that arose while logging.- Specified by:
handle
in interfaceErrorHandler
- Parameters:
exception
- the exception that occurredlogger
- the logger that was being processed that caused the error to occur
-
reset
Resets all error counts and reenables all loggers.
-