Package org.chsrobotics.lib.telemetry
Class Logger<T>
java.lang.Object
org.chsrobotics.lib.telemetry.Logger<T>
- Type Parameters:
T- The data type of the log entry.
Utility to streamline publishing data to NetworkTables and saving it to an on-robot log file.
Parameterized to the type of data to publish/log.
If the data isn't numerical (Double, Int, Long, etc), Boolean, String, or an Array of one of
those types, this will instead publish and log the result of its .toString() method.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classFactory class to simplify creating many similar logs at once. -
Constructor Summary
ConstructorsConstructorDescriptionLogger(edu.wpi.first.util.datalog.DataLog log, String key, String subdirName, boolean publishToNT, boolean recordInLog) Constructs a Logger using a provided DataLog, with the option of whether to publish to NT and the log.Constructs a Logger usingHighLevelLogger.getLog(), publishing to NT and logging. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns whether this is publishing values to NetworkTables.booleanReturns whether this is recording values to the on-robot log.voidNew values sent toupdate()will be pushed to NetworkTables.voidNew values sent toupdate()will be recorded to the log.voidNew values sent toupdate()will not be pushed to NetworkTables.voidNew values sent toupdate()will not be recorded to the log.voidFeeds a new value to the Logger, which may be sent to NetworkTables, an on-robot log, both, or neither, depending on how this class is configured.
-
Constructor Details
-
Logger
public Logger(edu.wpi.first.util.datalog.DataLog log, String key, String subdirName, boolean publishToNT, boolean recordInLog) Constructs a Logger using a provided DataLog, with the option of whether to publish to NT and the log.- Parameters:
log- The DataLog to log values inside of, most likely fromHighLevelLogger.getLog()or whatever log is being used program-wide.key- A string identifier to associate with and describe the data on the dashboard. In the log, the string identifier will be "[subdirName]_[key]".subdirName- The string name of the existing or new NetworkTables sub-table to write to.publishToNT- Whether this should push logged values to NetworkTables.recordInLog- Whether this should store logged values in an on-robot log file.
-
Logger
Constructs a Logger usingHighLevelLogger.getLog(), publishing to NT and logging.- Parameters:
key- A string identifier to associate with and describe the data on the dashboard. In the log, the string identifier will be "[subdirName]_[key]".subdirName- The string name of the existing or new NetworkTables sub-table to write to.
-
-
Method Details
-
isPublishingToNT
public boolean isPublishingToNT()Returns whether this is publishing values to NetworkTables.- Returns:
- True if new values sent to
update()will be pushed to the dashboard.
-
startPublishingToDashboard
public void startPublishingToDashboard()New values sent toupdate()will be pushed to NetworkTables. -
stopPublishingToDashboard
public void stopPublishingToDashboard()New values sent toupdate()will not be pushed to NetworkTables. -
isRecordingToLog
public boolean isRecordingToLog()Returns whether this is recording values to the on-robot log.- Returns:
- True if new values sent to
update()will be recorded to the log.
-
startRecordingToLog
public void startRecordingToLog()New values sent toupdate()will be recorded to the log. -
stopRecordingToLog
public void stopRecordingToLog()New values sent toupdate()will not be recorded to the log. -
update
Feeds a new value to the Logger, which may be sent to NetworkTables, an on-robot log, both, or neither, depending on how this class is configured.- Parameters:
value- An instance of T (whatever this class was parameterized with).
-