Class Logger
The recordVerboseOutput family of methods gates on both FMS attachment and the per-instance
verbose flag. Verbose output is suppressed when the robot is connected to the FMS or when the
owning subsystem has verbose disabled in its configuration. Use recordOutput for data
that must always be logged for match replay.
For robot mode detection, FMS state, and Driver Station reporting, see RobotEnvironment.
-
Constructor Summary
ConstructorsModifierConstructorDescriptionprotectedLogger(String className, BooleanSupplier verboseSupplier) Creates a logger scoped to the provided class name. -
Method Summary
Modifier and TypeMethodDescriptionvoidDismisses both the error and warning dashboard alerts.voidLogs a debug message to the console if verbose output is enabled.voidLogs an error message to the standard error console and activates a persistent dashboardAlert.static <T> LoggergetInstance(Class<T> c) Returns an instance of Logger for the specified classstatic <T> LoggergetInstance(Class<T> c, boolean verbose) Returns an instance of Logger for the specified class with a fixed verbosity setting.static <T> LoggergetInstance(Class<T> c, BooleanSupplier verboseSupplier) Returns an instance of Logger for the specified class with a dynamic verbosity supplier.static LoggergetInstance(String className) Returns an instance of Logger for the specified namestatic LoggergetInstance(String className, boolean verbose) Returns an instance of Logger for the specified name with a fixed verbosity setting.static LoggergetInstance(String className, BooleanSupplier verboseSupplier) Returns an instance of Logger for the specified name with a dynamic verbosity supplier.voidLogs an informational message to the console.voidprocessInputs(String key, org.littletonrobotics.junction.inputs.LoggableInputs inputs) Records an auto-logged input snapshot with the logger prefix applied.voidrecordOutput(String key, boolean value) Records a boolean to AdvantageKit using the class name as a prefix.voidrecordOutput(String key, double value) Records a numeric value to AdvantageKit using the class name as a prefix.voidrecordOutput(String key, double[] values) Records an array of numeric values to AdvantageKit using the class name as a prefix.voidrecordOutput(String key, String value) Records a string value to AdvantageKit using the class name as a prefix.<T extends edu.wpi.first.util.struct.StructSerializable>
voidrecordOutput(String key, T value) Records a struct-serializable value to AdvantageKit using the class name as a prefix.<T extends edu.wpi.first.util.struct.StructSerializable>
voidrecordOutput(String key, T... value) Records an array of struct-serializable values to AdvantageKit using the class name as a prefix.<T extends edu.wpi.first.util.struct.StructSerializable>
voidrecordOutput(String key, T[][] value) Records a 2D array of struct-serializable values to AdvantageKit using the class name as a prefix.voidrecordVerboseOutput(String key, boolean value) Records a boolean to AdvantageKit only when not attached to the FMS and verbose is enabled.voidrecordVerboseOutput(String key, double value) Records a numeric value to AdvantageKit only when not attached to the FMS and verbose is enabled.voidrecordVerboseOutput(String key, double[] values) Records an array of numeric values to AdvantageKit only when not attached to the FMS and verbose is enabled.voidrecordVerboseOutput(String key, String value) Records a string value to AdvantageKit only when not attached to the FMS and verbose is enabled.<T extends edu.wpi.first.util.struct.StructSerializable>
voidrecordVerboseOutput(String key, T value) Records a struct-serializable value to AdvantageKit only when not attached to the FMS and verbose is enabled.<T extends edu.wpi.first.util.struct.StructSerializable>
voidrecordVerboseOutput(String key, T... value) Records an array of struct-serializable values to AdvantageKit only when not attached to the FMS and verbose is enabled.<T extends edu.wpi.first.util.struct.StructSerializable>
voidrecordVerboseOutput(String key, T[][] value) Records a 2D array of struct-serializable values to AdvantageKit only when not attached to the FMS and verbose is enabled.voidLogs a verbose message to the console if verbose output is enabled.voidLogs a warning message to the console and activates a persistent dashboardAlert.
-
Constructor Details
-
Logger
Creates a logger scoped to the provided class name.Two persistent
Alertinstances are created using the class name as the alert group so dashboard alerts are organized per-subsystem. Alerts remain active until explicitly cleared viaclearAlerts().- Parameters:
className- name to prefix all log messages withverboseSupplier- supplier evaluated each cycle to determine whether verbose output is enabled
-
-
Method Details
-
getInstance
Returns an instance of Logger for the specified class- Type Parameters:
T- the type of the class for which the Logger instance is being created- Parameters:
c- the Class object for which the Logger instance is being created- Returns:
- a new Logger instance for the specified class with the given verbosity setting
-
getInstance
Returns an instance of Logger for the specified class with a fixed verbosity setting.- Type Parameters:
T- the type of the class for which the Logger instance is being created- Parameters:
c- the Class object for which the Logger instance is being createdverbose- the verbosity setting for the logger- Returns:
- a new Logger instance for the specified class with the given verbosity setting
-
getInstance
Returns an instance of Logger for the specified class with a dynamic verbosity supplier.The supplier is evaluated each time the logger checks verbosity, allowing live toggling from dashboards without calling
setVerbose.- Type Parameters:
T- the type of the class for which the Logger instance is being created- Parameters:
c- the Class object for which the Logger instance is being createdverboseSupplier- supplier that returns true when verbose output should be enabled- Returns:
- a new Logger instance for the specified class with the given verbosity supplier
-
getInstance
Returns an instance of Logger for the specified name- Parameters:
className- the name to scope the logger instance to- Returns:
- a new Logger instance for the specified class with the given verbosity setting
-
getInstance
Returns an instance of Logger for the specified name with a fixed verbosity setting.- Parameters:
className- the name to scope the logger instance toverbose- the verbosity setting for the logger- Returns:
- a new Logger instance for the specified class with the given verbosity setting
-
getInstance
Returns an instance of Logger for the specified name with a dynamic verbosity supplier.The supplier is evaluated each time the logger checks verbosity, allowing live toggling from dashboards without calling
setVerbose.- Parameters:
className- the name to scope the logger instance toverboseSupplier- supplier that returns true when verbose output should be enabled- Returns:
- a new Logger instance for the specified class with the given verbosity supplier
-
verbose
Logs a verbose message to the console if verbose output is enabled. The message is prefixed with "VERBOSE:" and the class name, and is displayed in gray color.- Parameters:
message- The message to be logged.
-
debug
Logs a debug message to the console if verbose output is enabled. The message is prefixed with "DEBUG:" and the class name, and is displayed in white color.- Parameters:
message- The debug message to be logged.
-
info
Logs an informational message to the console. The message is prefixed with "INFO:" and the class name, and is displayed in white color.- Parameters:
message- The informational message to be logged.
-
warning
Logs a warning message to the console and activates a persistent dashboardAlert.The alert remains visible on supported dashboards until dismissed via
clearAlerts(). Each call replaces the previous warning text, so only the most recent warning is displayed.- Parameters:
message- The warning message to be logged.
-
error
Logs an error message to the standard error console and activates a persistent dashboardAlert.The alert remains visible on supported dashboards until dismissed via
clearAlerts(). Each call replaces the previous error text, so only the most recent error is displayed.- Parameters:
message- The error message to be logged.
-
clearAlerts
public void clearAlerts()Dismisses both the error and warning dashboard alerts.Call this when a previously reported condition has recovered so stale alerts do not remain visible to operators. Safe to call even if no alerts are currently active.
-
recordOutput
Records a boolean to AdvantageKit using the class name as a prefix. Prefer this for telemetry instead of SmartDashboard to reduce NetworkTables noise.- Parameters:
key- telemetry key suffixvalue- value to record
-
recordOutput
Records a numeric value to AdvantageKit using the class name as a prefix. Prefer this for telemetry instead of SmartDashboard to reduce NetworkTables noise.- Parameters:
key- telemetry key suffixvalue- value to record
-
recordOutput
Records an array of numeric values to AdvantageKit using the class name as a prefix.- Parameters:
key- telemetry key suffixvalues- values to record
-
recordOutput
Records a string value to AdvantageKit using the class name as a prefix.- Parameters:
key- telemetry key suffixvalue- string value to record
-
recordOutput
public <T extends edu.wpi.first.util.struct.StructSerializable> void recordOutput(String key, T value) Records a struct-serializable value to AdvantageKit using the class name as a prefix.Use this for WPILib types that implement
StructSerializable(poses, rotations, chassis speeds, module states, etc.).- Type Parameters:
T- value type that supports struct serialization- Parameters:
key- telemetry key suffixvalue- struct-serializable value to record
-
recordOutput
public <T extends edu.wpi.first.util.struct.StructSerializable> void recordOutput(String key, T... value) Records an array of struct-serializable values to AdvantageKit using the class name as a prefix.This matches AdvantageKit's struct array logging for types like module states or pose lists.
- Type Parameters:
T- value type that supports struct serialization- Parameters:
key- telemetry key suffixvalue- struct-serializable values to record
-
recordOutput
public <T extends edu.wpi.first.util.struct.StructSerializable> void recordOutput(String key, T[][] value) Records a 2D array of struct-serializable values to AdvantageKit using the class name as a prefix.- Type Parameters:
T- value type that supports struct serialization- Parameters:
key- telemetry key suffixvalue- struct-serializable values to record
-
processInputs
Records an auto-logged input snapshot with the logger prefix applied.- Parameters:
key- input key suffix for AdvantageKitinputs- auto-logged inputs bundle to record
-
recordVerboseOutput
Records a string value to AdvantageKit only when not attached to the FMS and verbose is enabled.- Parameters:
key- telemetry key suffixvalue- string value to record
-
recordVerboseOutput
Records a boolean to AdvantageKit only when not attached to the FMS and verbose is enabled.- Parameters:
key- telemetry key suffixvalue- value to record
-
recordVerboseOutput
Records a numeric value to AdvantageKit only when not attached to the FMS and verbose is enabled.- Parameters:
key- telemetry key suffixvalue- value to record
-
recordVerboseOutput
Records an array of numeric values to AdvantageKit only when not attached to the FMS and verbose is enabled.- Parameters:
key- telemetry key suffixvalues- values to record
-
recordVerboseOutput
public <T extends edu.wpi.first.util.struct.StructSerializable> void recordVerboseOutput(String key, T value) Records a struct-serializable value to AdvantageKit only when not attached to the FMS and verbose is enabled.- Type Parameters:
T- value type that supports struct serialization- Parameters:
key- telemetry key suffixvalue- struct-serializable value to record
-
recordVerboseOutput
public <T extends edu.wpi.first.util.struct.StructSerializable> void recordVerboseOutput(String key, T... value) Records an array of struct-serializable values to AdvantageKit only when not attached to the FMS and verbose is enabled.- Type Parameters:
T- value type that supports struct serialization- Parameters:
key- telemetry key suffixvalue- struct-serializable values to record
-
recordVerboseOutput
public <T extends edu.wpi.first.util.struct.StructSerializable> void recordVerboseOutput(String key, T[][] value) Records a 2D array of struct-serializable values to AdvantageKit only when not attached to the FMS and verbose is enabled.- Type Parameters:
T- value type that supports struct serialization- Parameters:
key- telemetry key suffixvalue- struct-serializable values to record
-