001// Copyright (c) FIRST and other WPILib contributors.
002// Open Source Software; you can modify and/or share it under the terms of
003// the WPILib BSD license file in the root directory of this project.
004
005package edu.wpi.first.util.datalog;
006
007/** Log string values. */
008public class StringLogEntry extends DataLogEntry {
009  /** The data type for string values. */
010  public static final String kDataType = "string";
011
012  /**
013   * Constructs a String log entry.
014   *
015   * @param log datalog
016   * @param name name of the entry
017   * @param metadata metadata
018   * @param type Data type
019   * @param timestamp entry creation timestamp (0=now)
020   */
021  public StringLogEntry(DataLog log, String name, String metadata, String type, long timestamp) {
022    super(log, name, type, metadata, timestamp);
023  }
024
025  /**
026   * Constructs a String log entry.
027   *
028   * @param log datalog
029   * @param name name of the entry
030   * @param metadata metadata
031   * @param type Data type
032   */
033  public StringLogEntry(DataLog log, String name, String metadata, String type) {
034    this(log, name, metadata, type, 0);
035  }
036
037  /**
038   * Constructs a String log entry.
039   *
040   * @param log datalog
041   * @param name name of the entry
042   * @param metadata metadata
043   * @param timestamp entry creation timestamp (0=now)
044   */
045  public StringLogEntry(DataLog log, String name, String metadata, long timestamp) {
046    this(log, name, metadata, kDataType, timestamp);
047  }
048
049  /**
050   * Constructs a String log entry.
051   *
052   * @param log datalog
053   * @param name name of the entry
054   * @param metadata metadata
055   */
056  public StringLogEntry(DataLog log, String name, String metadata) {
057    this(log, name, metadata, 0);
058  }
059
060  /**
061   * Constructs a String log entry.
062   *
063   * @param log datalog
064   * @param name name of the entry
065   * @param timestamp entry creation timestamp (0=now)
066   */
067  public StringLogEntry(DataLog log, String name, long timestamp) {
068    this(log, name, "", timestamp);
069  }
070
071  /**
072   * Constructs a String log entry.
073   *
074   * @param log datalog
075   * @param name name of the entry
076   */
077  public StringLogEntry(DataLog log, String name) {
078    this(log, name, 0);
079  }
080
081  /**
082   * Appends a record to the log.
083   *
084   * @param value Value to record
085   * @param timestamp Time stamp (0 to indicate now)
086   */
087  public void append(String value, long timestamp) {
088    m_log.appendString(m_entry, value, timestamp);
089  }
090
091  /**
092   * Appends a record to the log.
093   *
094   * @param value Value to record
095   */
096  public void append(String value) {
097    m_log.appendString(m_entry, value, 0);
098  }
099}