WPILibC++ 2024.3.2
frc::DataLogManager Class Referencefinal

Centralized data log that provides automatic data log file management. More...

#include <frc/DataLogManager.h>

Public Member Functions

 DataLogManager ()=delete
 

Static Public Member Functions

static void Start (std::string_view dir="", std::string_view filename="", double period=0.25)
 Start data log manager. More...
 
static void Stop ()
 Stop data log manager. More...
 
static void Log (std::string_view message)
 Log a message to the "messages" entry. More...
 
static wpi::log::DataLogGetLog ()
 Get the managed data log (for custom logging). More...
 
static std::string GetLogDir ()
 Get the log directory. More...
 
static void LogNetworkTables (bool enabled)
 Enable or disable logging of NetworkTables data. More...
 

Detailed Description

Centralized data log that provides automatic data log file management.

It automatically cleans up old files when disk space is low and renames the file based either on current date/time or (if available) competition match number. The data file will be saved to a USB flash drive in a folder named "logs" if one is attached, or to /home/lvuser/logs otherwise.

Log files are initially named "FRC_TBD_{random}.wpilog" until the DS connects. After the DS connects, the log file is renamed to "FRC_yyyyMMdd_HHmmss.wpilog" (where the date/time is UTC). If the FMS is connected and provides a match number, the log file is renamed to "FRC_yyyyMMdd_HHmmss_{event}_{match}.wpilog".

On startup, all existing FRC_TBD log files are deleted. If there is less than 50 MB of free space on the target storage, FRC_ log files are deleted (oldest to newest) until there is 50 MB free OR there are 10 files remaining.

By default, all NetworkTables value changes are stored to the data log.

Constructor & Destructor Documentation

◆ DataLogManager()

frc::DataLogManager::DataLogManager ( )
delete

Member Function Documentation

◆ GetLog()

static wpi::log::DataLog & frc::DataLogManager::GetLog ( )
static

Get the managed data log (for custom logging).

Starts the data log manager if not already started.

Returns
data log

◆ GetLogDir()

static std::string frc::DataLogManager::GetLogDir ( )
static

Get the log directory.

Returns
log directory

◆ Log()

static void frc::DataLogManager::Log ( std::string_view  message)
static

Log a message to the "messages" entry.

The message is also printed to standard output (followed by a newline).

Parameters
messagemessage

◆ LogNetworkTables()

static void frc::DataLogManager::LogNetworkTables ( bool  enabled)
static

Enable or disable logging of NetworkTables data.

Note that unlike the network interface for NetworkTables, this will capture every value change. Defaults to enabled.

Parameters
enabledtrue to enable, false to disable

◆ Start()

static void frc::DataLogManager::Start ( std::string_view  dir = "",
std::string_view  filename = "",
double  period = 0.25 
)
static

Start data log manager.

The parameters have no effect if the data log manager was already started (e.g. by calling another static function).

Parameters
dirif not empty, directory to use for data log storage
filenamefilename to use; if none provided, the filename is automatically generated
periodtime between automatic flushes to disk, in seconds; this is a time/storage tradeoff

◆ Stop()

static void frc::DataLogManager::Stop ( )
static

Stop data log manager.


The documentation for this class was generated from the following file: