Class DogLog
java.lang.Object
dev.doglog.DogLog
A logger based on WPILib's
DataLogManager-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static booleanWhether the logger is enabled.protected static final EpochLoggerprotected static LogWriterHighLevelprotected static DogLogOptionsThe options to use for the logger.protected static final Tunable -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidclearFault(@Nullable Enum<?> faultName) Reset the count of a fault to 0, and set the alert associated with the fault to inactive if possible.static voidclearFault(@Nullable String faultName) Reset the count of a fault to 0, and set the alert associated with the fault to inactive if possible.static voiddecreaseFault(@Nullable Enum<?> faultName) Lower the count of a fault by 1, unless it is already at 0.static voiddecreaseFault(@Nullable String faultName) Lower the count of a fault by 1, unless it is already at 0.static booleanCheck if any faults logged using logged usinglogFault(String)are currently active.static booleanCheck if faults have been logged usinglogFault(String).static DogLogOptionsGet the options used by the logger.static booleanReturns whether the logger is enabled.static voidLog a boolean.static voidLog a boolean array.static voidLog a double.static voidLog a double array.static voidLog a double array with unit metadata.static voidLog a double array with unit metadata.static voidLog a double with unit metadata.static voidLog a double with unit metadata.static voidLog a float.static voidLog a float array.static voidLog a float array with unit metadata.static voidLog a float with unit metadata.static voidLog an int array.static voidLog a long.static voidLog a long array.static voidLog a long array with unit metadata.static voidLog a long with unit metadata.static <T extends StructSerializable>
voidLog a struct.static <T extends StructSerializable>
voidLog a struct array.static voidLog a measure, preserving the user-specified unit.static voidLog an enum.static voidLog an enum array.static voidLog a string.static voidLog a string array.static voidLog a string with a custom type string.static voidLog a fault and create an error typeAlertfor it.static voidLog a fault and create an error typeAlertfor it.static voidlogFault(@Nullable String faultName, @Nullable Alert.AlertType alertType) Log a fault and create anAlertfor it at the specified level.static voidsetEnabled(boolean newEnabled) Set whether the logger is enabled.static voidsetOptions(@Nullable DogLogOptions newOptions) Update the options used by the logger.static voidSet thePowerDistributioninstance to use for logging PDH/PDP data when logging extras is enabled.static voidStart a timer to track how long an operation takes to execute.static CommandWraps aCommandwith a timer that records how long the command runs.static voidStop a timer started withtime(String)and log the duration in seconds to the specified key.static voidLog the current FPGA timestamp.static BooleanSubscriberCreate a tunable boolean.static BooleanSubscribertunable(String key, boolean defaultValue, @Nullable BooleanConsumer onChange) Create a tunable boolean.static DoubleSubscriberCreate a tunable double.static DoubleSubscriberCreate a tunable double with unit metadata.static DoubleSubscriberCreate a tunable double with unit metadata.static DoubleSubscriberCreate a tunable double with unit metadata.static DoubleSubscriberCreate a tunable double with unit metadata.static DoubleSubscribertunable(String key, double defaultValue, @Nullable DoubleConsumer onChange) Create a tunable double.static FloatSubscriberCreate a tunable float.static FloatSubscriberCreate a tunable float with unit metadata.static FloatSubscriberCreate a tunable float with unit metadata.static FloatSubscribertunable(String key, float defaultValue, @Nullable FloatConsumer onChange) Create a tunable float.static FloatSubscriberCreate a tunable float with unit metadata.static FloatSubscribertunable(String key, float defaultValue, String unit, @Nullable FloatConsumer onChange) Create a tunable float with unit metadata.static IntegerSubscriberCreate a tunable integer.static IntegerSubscriberCreate a tunable integer with unit metadata.static IntegerSubscriberCreate a tunable integer with unit metadata.static IntegerSubscriberCreate a tunable integer with unit metadata.static IntegerSubscriberCreate a tunable integer with unit metadata.static IntegerSubscribertunable(String key, long defaultValue, @Nullable LongConsumer onChange) Create a tunable integer.static DoubleSubscriberCreate a tunable from a measure, preserving the user-specified unit.static DoubleSubscribertunable(String key, Measure<?> defaultValue, @Nullable DoubleConsumer onChange) Create a tunable from a measure, preserving the user-specified unit.static StringSubscriberCreate a tunable string.static StringSubscriberCreate a tunable string.
-
Field Details
-
options
The options to use for the logger. -
logger
-
enabled
protected static boolean enabledWhether the logger is enabled. -
tunable
-
epochLogger
-
-
Constructor Details
-
DogLog
protected DogLog()
-
-
Method Details
-
getOptions
Get the options used by the logger. -
setOptions
Update the options used by the logger.Example:
DogLog.setOptions(new DogLogOptions().withNtPublish(true));
See https://doglog.dev/reference/logger-options/ for more information.
-
setPdh
Set thePowerDistributioninstance to use for logging PDH/PDP data when logging extras is enabled. If this is set to `null`, no PDH data will be logged. Otherwise, information like battery voltage, device currents, etc. will be logged.Example:
DogLog.setPdh(new PowerDistribution());
- Parameters:
pdh- ThePowerDistributioninstance to use for logging PDH/PDP data.
-
setEnabled
public static void setEnabled(boolean newEnabled) Set whether the logger is enabled. If the logger is not enabled, calls to `log()` functions will not do anything.By default, the logger is enabled.
-
isEnabled
public static boolean isEnabled()Returns whether the logger is enabled.- See Also:
-
log
-
log
Log a boolean. -
log
-
log
-
log
-
log
Log a double. -
log
-
log
-
log
-
log
-
log
-
log
Log a float. -
log
-
log
-
log
-
log
-
log
Log a long. -
log
-
log
-
log
Log an enum array. Enums will be converted to strings withEnum.name(). -
log
-
log
-
log
Log an enum. The enum will be converted to a string withEnum.name(). -
log
Log a struct array. -
log
Log a struct. -
logFault
Log a fault and create anAlertfor it at the specified level.See https://doglog.dev/guides/faults for more information.
- Parameters:
faultName- The name of the fault to log.alertType- The type of alert to create for the fault, ornullif it should not create an alert- See Also:
-
logFault
-
logFault
Log a fault and create an error typeAlertfor it. The enum will be converted to a string withEnum.name().See https://doglog.dev/guides/faults for more information.
- Parameters:
faultName- The name of the fault to log.- See Also:
-
decreaseFault
Lower the count of a fault by 1, unless it is already at 0. If there is an alert associated with the fault, it will be set to inactive once the fault's count is 0.- Parameters:
faultName- The name of the fault to decrement the count of.- See Also:
-
decreaseFault
Lower the count of a fault by 1, unless it is already at 0. If there is an alert associated with the fault, it will be set to inactive once the fault's count is 0.- Parameters:
faultName- The name of the fault to decrement the count of.- See Also:
-
clearFault
-
clearFault
-
faultsLogged
public static boolean faultsLogged()Check if faults have been logged usinglogFault(String).- Returns:
- Whether any faults have been logged.
-
faultsActive
public static boolean faultsActive()Check if any faults logged using logged usinglogFault(String)are currently active.- Returns:
- Whether any faults are currently active.
-
timestamp
Log the current FPGA timestamp. Useful for recording each time a block of code is executed, since timestamps are unique and monotonically increasing.- Parameters:
key- The key to log the timestamp to.
-
time
Start a timer to track how long an operation takes to execute. When you calltimeEnd(String)the duration of the operation in seconds will be logged to the specified key.- Parameters:
key- The key to start the timer for.- See Also:
-
time
-
timeEnd
Stop a timer started withtime(String)and log the duration in seconds to the specified key.- Parameters:
key- The key to stop the timer for.- See Also:
-
tunable
Create a tunable double.- Parameters:
key- The key for the tunable value.defaultValue- The default value for the tunable value.- Returns:
- A
DoubleSubscriberused to retrieve the tunable value.
-
tunable
public static DoubleSubscriber tunable(String key, double defaultValue, @Nullable DoubleConsumer onChange) Create a tunable double.- Parameters:
key- The key for the tunable value.defaultValue- The default value for the tunable value.onChange- A function to call when the tunable value changes.- Returns:
- A
DoubleSubscriberused to retrieve the tunable value.
-
tunable
Create a tunable double with unit metadata.- Parameters:
key- The key for the tunable value.defaultValue- The default value for the tunable value.unit- The unit for the tunable value.- Returns:
- A
DoubleSubscriberused to retrieve the tunable value.
-
tunable
public static DoubleSubscriber tunable(String key, double defaultValue, @Nullable String unit, @Nullable DoubleConsumer onChange) Create a tunable double with unit metadata.- Parameters:
key- The key for the tunable value.defaultValue- The default value for the tunable value.unit- The unit for the tunable value.onChange- A function to call when the tunable value changes.- Returns:
- A
DoubleSubscriberused to retrieve the tunable value.
-
tunable
Create a tunable double with unit metadata.- Parameters:
key- The key for the tunable value.defaultValue- The default value for the tunable value.unit- The unit for the tunable value.- Returns:
- A
DoubleSubscriberused to retrieve the tunable value.
-
tunable
public static DoubleSubscriber tunable(String key, double defaultValue, @Nullable Unit unit, @Nullable DoubleConsumer onChange) Create a tunable double with unit metadata.- Parameters:
key- The key for the tunable value.defaultValue- The default value for the tunable value.unit- The unit for the tunable value.onChange- A function to call when the tunable value changes.- Returns:
- A
DoubleSubscriberused to retrieve the tunable value.
-
tunable
Create a tunable from a measure, preserving the user-specified unit.- Parameters:
key- The key for the tunable value.defaultValue- The default measure value for the tunable value.- Returns:
- A
DoubleSubscriberused to retrieve the tunable value.
-
tunable
public static DoubleSubscriber tunable(String key, Measure<?> defaultValue, @Nullable DoubleConsumer onChange) Create a tunable from a measure, preserving the user-specified unit.- Parameters:
key- The key for the tunable value.defaultValue- The default measure value for the tunable value.onChange- A function to call when the tunable value changes.- Returns:
- A
DoubleSubscriberused to retrieve the tunable value.
-
tunable
Create a tunable float.- Parameters:
key- The key for the tunable value.defaultValue- The default value for the tunable value.- Returns:
- A
FloatSubscriberused to retrieve the tunable value.
-
tunable
public static FloatSubscriber tunable(String key, float defaultValue, @Nullable FloatConsumer onChange) Create a tunable float.- Parameters:
key- The key for the tunable value.defaultValue- The default value for the tunable value.onChange- A function to call when the tunable value changes.- Returns:
- A
FloatSubscriberused to retrieve the tunable value.
-
tunable
Create a tunable float with unit metadata.- Parameters:
key- The key for the tunable value.defaultValue- The default value for the tunable value.unit- The unit for the tunable value.- Returns:
- A
FloatSubscriberused to retrieve the tunable value.
-
tunable
public static FloatSubscriber tunable(String key, float defaultValue, String unit, @Nullable FloatConsumer onChange) Create a tunable float with unit metadata.- Parameters:
key- The key for the tunable value.defaultValue- The default value for the tunable value.unit- The unit for the tunable value.onChange- A function to call when the tunable value changes.- Returns:
- A
FloatSubscriberused to retrieve the tunable value.
-
tunable
Create a tunable float with unit metadata.- Parameters:
key- The key for the tunable value.defaultValue- The default value for the tunable value.unit- The unit for the tunable value.- Returns:
- A
FloatSubscriberused to retrieve the tunable value.
-
tunable
public static FloatSubscriber tunable(String key, float defaultValue, @Nullable Unit unit, @Nullable FloatConsumer onChange) Create a tunable float with unit metadata.- Parameters:
key- The key for the tunable value.defaultValue- The default value for the tunable value.unit- The unit for the tunable value.onChange- A function to call when the tunable value changes.- Returns:
- A
FloatSubscriberused to retrieve the tunable value.
-
tunable
Create a tunable boolean.- Parameters:
key- The key for the tunable value.defaultValue- The default value for the tunable value.- Returns:
- A
BooleanSubscriberused to retrieve the tunable value.
-
tunable
public static BooleanSubscriber tunable(String key, boolean defaultValue, @Nullable BooleanConsumer onChange) Create a tunable boolean.- Parameters:
key- The key for the tunable value.defaultValue- The default value for the tunable value.onChange- A function to call when the tunable value changes.- Returns:
- A
BooleanSubscriberused to retrieve the tunable value.
-
tunable
Create a tunable string.- Parameters:
key- The key for the tunable value.defaultValue- The default value for the tunable value.- Returns:
- A
StringSubscriberused to retrieve the tunable value.
-
tunable
public static StringSubscriber tunable(String key, String defaultValue, @Nullable Consumer<String> onChange) Create a tunable string.- Parameters:
key- The key for the tunable value.defaultValue- The default value for the tunable value.onChange- A function to call when the tunable value changes.- Returns:
- A
StringSubscriberused to retrieve the tunable value.
-
tunable
Create a tunable integer.- Parameters:
key- The key for the tunable value.defaultValue- The default value for the tunable value.- Returns:
- An
IntegerSubscriberused to retrieve the tunable value.
-
tunable
public static IntegerSubscriber tunable(String key, long defaultValue, @Nullable LongConsumer onChange) Create a tunable integer.- Parameters:
key- The key for the tunable value.defaultValue- The default value for the tunable value.onChange- A function to call when the tunable value changes.- Returns:
- An
IntegerSubscriberused to retrieve the tunable value.
-
tunable
Create a tunable integer with unit metadata.- Parameters:
key- The key for the tunable value.defaultValue- The default value for the tunable value.unit- The unit for the tunable value.- Returns:
- An
IntegerSubscriberused to retrieve the tunable value.
-
tunable
public static IntegerSubscriber tunable(String key, long defaultValue, @Nullable String unit, @Nullable LongConsumer onChange) Create a tunable integer with unit metadata.- Parameters:
key- The key for the tunable value.defaultValue- The default value for the tunable value.unit- The unit for the tunable value.onChange- A function to call when the tunable value changes.- Returns:
- An
IntegerSubscriberused to retrieve the tunable value.
-
tunable
Create a tunable integer with unit metadata.- Parameters:
key- The key for the tunable value.defaultValue- The default value for the tunable value.unit- The unit for the tunable value.- Returns:
- An
IntegerSubscriberused to retrieve the tunable value.
-
tunable
public static IntegerSubscriber tunable(String key, long defaultValue, @Nullable Unit unit, @Nullable LongConsumer onChange) Create a tunable integer with unit metadata.- Parameters:
key- The key for the tunable value.defaultValue- The default value for the tunable value.unit- The unit for the tunable value.onChange- A function to call when the tunable value changes.- Returns:
- An
IntegerSubscriberused to retrieve the tunable value.
-