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 org.wpilib.datalog; 006 007/** 008 * A class version of `tail -f`, otherwise known as `tail -f` at home. Watches a file and puts the 009 * data into a data log. Only works on Linux-based platforms. 010 */ 011public class FileLogger implements AutoCloseable { 012 private final long m_impl; 013 014 /** 015 * Construct a FileLogger. When the specified file is modified, appended data will be appended to 016 * the specified data log. 017 * 018 * @param file The path to the file. 019 * @param log A data log. 020 * @param key The log key to append data to. 021 */ 022 public FileLogger(String file, DataLog log, String key) { 023 m_impl = DataLogJNI.createFileLogger(file, log.getImpl(), key); 024 } 025 026 @Override 027 public void close() { 028 DataLogJNI.freeFileLogger(m_impl); 029 } 030}