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.
public class Logger<T> extends java.lang.ObjectUtility 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.
-
-
Constructor Summary
Constructors Constructor Description Logger(edu.wpi.first.util.datalog.DataLog log, java.lang.String key, java.lang.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.Logger(java.lang.String key, java.lang.String subdirName)Constructs a Logger usingHighLevelLogger.getLog(), publishing to NT and logging.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description booleanisPublishingToNT()Returns whether this is publishing values to NetworkTables.booleanisRecordingToLog()Returns whether this is recording values to the on-robot log.voidstartPublishingToDashboard()New values sent toupdate()will be pushed to NetworkTables.voidstartRecordingToLog()New values sent toupdate()will be recorded to the log.voidstopPublishingToDashboard()New values sent toupdate()will not be pushed to NetworkTables.voidstopRecordingToLog()New values sent toupdate()will not be recorded to the log.voidupdate(T value)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.
-
-
-
Constructor Detail
-
Logger
public Logger(edu.wpi.first.util.datalog.DataLog log, java.lang.String key, java.lang.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
public Logger(java.lang.String key, java.lang.String subdirName)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 Detail
-
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
public void update(T value)
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).
-
-