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 Object
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 Classes
    Modifier and Type
    Class
    Description
    static class 
    Factory class to simplify creating many similar logs at once.
  • Constructor Summary

    Constructors
    Constructor
    Description
    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.
    Logger(String key, String subdirName)
    Constructs a Logger using HighLevelLogger.getLog(), publishing to NT and logging.
  • Method Summary

    Modifier and Type
    Method
    Description
    boolean
    Returns whether this is publishing values to NetworkTables.
    boolean
    Returns whether this is recording values to the on-robot log.
    void
    New values sent to update() will be pushed to NetworkTables.
    void
    New values sent to update() will be recorded to the log.
    void
    New values sent to update() will not be pushed to NetworkTables.
    void
    New values sent to update() will not be recorded to the log.
    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.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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 from HighLevelLogger.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(String key, String subdirName)
      Constructs a Logger using HighLevelLogger.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 to update() will be pushed to NetworkTables.
    • stopPublishingToDashboard

      public void stopPublishingToDashboard()
      New values sent to update() 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 to update() will be recorded to the log.
    • stopRecordingToLog

      public void stopRecordingToLog()
      New values sent to update() 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).