REVLib - C++
Loading...
Searching...
No Matches
StatusLogger Class Referencefinal

#include <StatusLogger.h>

Public Member Functions

 StatusLogger ()=delete
 

Static Public Member Functions

static void Start ()
 
static void Stop ()
 
static void DisableAutoLogging ()
 
static void SetLogDirectory (std::string_view path)
 
static std::string GetLogDirectory ()
 

Detailed Description

Logs CAN traffic from REV devices to a REV binary log (.revlog), which AdvantageScope can open.

Logging starts automatically when the first REV device (SPARK, Servo Hub, detached encoder or A301) is created on a real robot. Every REV status frame is recorded from CAN_S0 and from each CAN bus a REV device is created on, including frames from devices your code never creates. The Driver Station state (enabled, mode) and match information are recorded too, so AdvantageScope can line the log up with other logs.

Where logs go: on SystemCore, the logs folder of a USB drive if one is attached when logging starts, otherwise /home/systemcore/logs. These are the same folders WPILib's DataLogManager uses. Use SetLogDirectory() to choose another folder.

File names: a log starts as REV_TBD_<random>.revlog. Once the Driver Station has been connected for a second and the system clock is set, it is renamed to REV_<yyyyMMdd>_<HHmmss>.revlog (UTC). When the FMS provides match information, it is renamed again to include the event and match, for example REV_20261010_183205_CASJ_Q12.revlog. REV_TBD_ files left by runs that never connected to a Driver Station are deleted the next time logging starts, so copy them off first if you need them.

USB drives: a drive connected while logging is reported with a warning and is used from the next start. If the drive being logged to is removed, an error is reported and logging continues in a new file in /home/systemcore/logs.

Simulation: StatusLogger never logs in simulation, and every method in this class does nothing there.

Constructor & Destructor Documentation

◆ StatusLogger()

StatusLogger::StatusLogger ( )
delete

Member Function Documentation

◆ Start()

void StatusLogger::Start ( )
static

Starts logging, or resumes logging after Stop().

In most cases this is not required, because logging starts automatically when the first REV device is created. Use it after DisableAutoLogging(), or to resume after Stop(). If no REV device has been created yet, the log file is opened now with the start time, and frames are recorded once the first device is created.

Does nothing in simulation.

See also
Stop()
DisableAutoLogging()

◆ Stop()

void StatusLogger::Stop ( )
static

Pauses logging.

While stopped, no data is written to the log. The log file stays open, and logging can be resumed at any time with Start().

Does nothing in simulation.

See also
Start()
DisableAutoLogging()

◆ DisableAutoLogging()

void StatusLogger::DisableAutoLogging ( )
static

Prevents logging from starting automatically.

IMPORTANT: Call this before any REV device is created, ideally as the first line of your robot's constructor. If automatic logging has already opened a log file, that file is closed, and deleted if nothing was written to it.

After calling this, nothing is logged until Start() is called.

Does nothing in simulation.

See also
Start()
Stop()

◆ SetLogDirectory()

void StatusLogger::SetLogDirectory ( std::string_view path)
static

Sets the folder logs are written to, and remembers it for later runs.

The folder is created if needed. If it can't be written to, a warning is reported and logs go to the automatic location instead (a USB drive if attached, otherwise /home/systemcore/logs).

If logging has already started, the current log file is closed and logging continues in a new file in the new folder. The folder is saved on the robot, so later runs log there from the start without calling this again. If the saved folder is unavailable at startup (for example, a USB drive that isn't attached), that run uses the automatic location and the setting is kept.

Does nothing in simulation.

Parameters
pathThe folder to log to, or an empty string to clear the saved folder and return to the automatic location
See also
GetLogDirectory()

◆ GetLogDirectory()

std::string StatusLogger::GetLogDirectory ( )
static

Gets the folder logs are being written to.

Returns
The folder of the current log file while logging. Otherwise, the folder set with SetLogDirectory(), or an empty string for the automatic location. Always empty in simulation.
See also
SetLogDirectory()

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