WPILibC++ 2025.0.0-alpha-1-10-g1ccd8d1
wpi::log::DataLogWriter Class Referencefinal

A data log writer that flushes the data log to a file when Flush() is called. More...

#include <wpi/DataLogWriter.h>

Inheritance diagram for wpi::log::DataLogWriter:
wpi::log::DataLog

Public Member Functions

 DataLogWriter (std::string_view filename, std::error_code &ec, std::string_view extraHeader="")
 Constructs with a filename. More...
 
 DataLogWriter (wpi::Logger &msglog, std::string_view filename, std::error_code &ec, std::string_view extraHeader="")
 Construct with a filename. More...
 
 DataLogWriter (std::unique_ptr< wpi::raw_ostream > os, std::string_view extraHeader="")
 Constructs with an output stream. More...
 
 DataLogWriter (wpi::Logger &msglog, std::unique_ptr< wpi::raw_ostream > os, std::string_view extraHeader="")
 Constructs with an output stream. More...
 
 ~DataLogWriter () final
 
 DataLogWriter (const DataLogWriter &)=delete
 
DataLogWriteroperator= (const DataLogWriter &)=delete
 
 DataLogWriter (DataLogWriter &&)=delete
 
DataLogWriteroperator= (const DataLogWriter &&)=delete
 
void Flush () final
 Flushes the log data to disk. More...
 
void Stop () final
 Stops appending all records to the log, and closes the log file. More...
 
- Public Member Functions inherited from wpi::log::DataLog
virtual ~DataLog ()=default
 
 DataLog (const DataLog &)=delete
 
DataLogoperator= (const DataLog &)=delete
 
 DataLog (DataLog &&)=delete
 
DataLogoperator= (const DataLog &&)=delete
 
virtual void Flush ()=0
 Explicitly flushes the log data to disk. More...
 
virtual void Pause ()
 Pauses appending of data records to the log. More...
 
virtual void Resume ()
 Resumes appending of data records to the log. More...
 
virtual void Stop ()
 Stops appending start/metadata/schema records to the log. More...
 
bool HasSchema (std::string_view name) const
 Returns whether there is a data schema already registered with the given name. More...
 
void AddSchema (std::string_view name, std::string_view type, std::span< const uint8_t > schema, int64_t timestamp=0)
 Registers a data schema. More...
 
void AddSchema (std::string_view name, std::string_view type, std::string_view schema, int64_t timestamp=0)
 Registers a data schema. More...
 
template<ProtobufSerializable T>
void AddProtobufSchema (ProtobufMessage< T > &msg, int64_t timestamp=0)
 Registers a protobuf schema. More...
 
template<typename T , typename... I>
requires StructSerializable<T, I...>
void AddStructSchema (const I &... info, int64_t timestamp=0)
 Registers a struct schema. More...
 
int Start (std::string_view name, std::string_view type, std::string_view metadata={}, int64_t timestamp=0)
 Start an entry. More...
 
void Finish (int entry, int64_t timestamp=0)
 Finish an entry. More...
 
void SetMetadata (int entry, std::string_view metadata, int64_t timestamp=0)
 Updates the metadata for an entry. More...
 
void AppendRaw (int entry, std::span< const uint8_t > data, int64_t timestamp)
 Appends a raw record to the log. More...
 
void AppendRaw2 (int entry, std::span< const std::span< const uint8_t > > data, int64_t timestamp)
 Appends a raw record to the log. More...
 
void AppendBoolean (int entry, bool value, int64_t timestamp)
 Appends a boolean record to the log. More...
 
void AppendInteger (int entry, int64_t value, int64_t timestamp)
 Appends an integer record to the log. More...
 
void AppendFloat (int entry, float value, int64_t timestamp)
 Appends a float record to the log. More...
 
void AppendDouble (int entry, double value, int64_t timestamp)
 Appends a double record to the log. More...
 
void AppendString (int entry, std::string_view value, int64_t timestamp)
 Appends a string record to the log. More...
 
void AppendBooleanArray (int entry, std::span< const bool > arr, int64_t timestamp)
 Appends a boolean array record to the log. More...
 
void AppendBooleanArray (int entry, std::span< const int > arr, int64_t timestamp)
 Appends a boolean array record to the log. More...
 
void AppendBooleanArray (int entry, std::span< const uint8_t > arr, int64_t timestamp)
 Appends a boolean array record to the log. More...
 
void AppendIntegerArray (int entry, std::span< const int64_t > arr, int64_t timestamp)
 Appends an integer array record to the log. More...
 
void AppendFloatArray (int entry, std::span< const float > arr, int64_t timestamp)
 Appends a float array record to the log. More...
 
void AppendDoubleArray (int entry, std::span< const double > arr, int64_t timestamp)
 Appends a double array record to the log. More...
 
void AppendStringArray (int entry, std::span< const std::string > arr, int64_t timestamp)
 Appends a string array record to the log. More...
 
void AppendStringArray (int entry, std::span< const std::string_view > arr, int64_t timestamp)
 Appends a string array record to the log. More...
 
void AppendStringArray (int entry, std::span< const struct WPI_String > arr, int64_t timestamp)
 Appends a string array record to the log. More...
 

Additional Inherited Members

- Protected Member Functions inherited from wpi::log::DataLog
 DataLog (wpi::Logger &msglog, std::string_view extraHeader="")
 Constructs the log. More...
 
void StartFile ()
 Starts the log. More...
 
void FlushBufs (std::vector< Buffer > *writeBufs)
 Provides complete set of all buffers that need to be written. More...
 
void ReleaseBufs (std::vector< Buffer > *bufs)
 Releases memory for a set of buffers back to the internal buffer pool. More...
 
virtual void BufferHalfFull ()
 Called when internal buffers are half the maximum count. More...
 
virtual bool BufferFull ()=0
 Called when internal buffers reach the maximum count. More...
 
- Protected Attributes inherited from wpi::log::DataLog
wpi::Loggerm_msglog
 
- Static Protected Attributes inherited from wpi::log::DataLog
static constexpr size_t kBlockSize = 16 * 1024
 
static wpi::Logger s_defaultMessageLog
 

Detailed Description

A data log writer that flushes the data log to a file when Flush() is called.

The lifetime of this object must be longer than any data log entry objects that refer to it.

Constructor & Destructor Documentation

◆ DataLogWriter() [1/6]

wpi::log::DataLogWriter::DataLogWriter ( std::string_view  filename,
std::error_code &  ec,
std::string_view  extraHeader = "" 
)
explicit

Constructs with a filename.

Parameters
filenamefilename to use
ecerror code if failed to open file (output)
extraHeaderextra header data

◆ DataLogWriter() [2/6]

wpi::log::DataLogWriter::DataLogWriter ( wpi::Logger msglog,
std::string_view  filename,
std::error_code &  ec,
std::string_view  extraHeader = "" 
)

Construct with a filename.

Parameters
msglogmessage logger
filenamefilename to use
ecerror code if failed to open file (output)
extraHeaderextra header data

◆ DataLogWriter() [3/6]

wpi::log::DataLogWriter::DataLogWriter ( std::unique_ptr< wpi::raw_ostream os,
std::string_view  extraHeader = "" 
)
explicit

Constructs with an output stream.

Parameters
osoutput stream
extraHeaderextra header data

◆ DataLogWriter() [4/6]

wpi::log::DataLogWriter::DataLogWriter ( wpi::Logger msglog,
std::unique_ptr< wpi::raw_ostream os,
std::string_view  extraHeader = "" 
)

Constructs with an output stream.

Parameters
msglogmessage logger
osoutput stream
extraHeaderextra header data

◆ ~DataLogWriter()

wpi::log::DataLogWriter::~DataLogWriter ( )
final

◆ DataLogWriter() [5/6]

wpi::log::DataLogWriter::DataLogWriter ( const DataLogWriter )
delete

◆ DataLogWriter() [6/6]

wpi::log::DataLogWriter::DataLogWriter ( DataLogWriter &&  )
delete

Member Function Documentation

◆ Flush()

void wpi::log::DataLogWriter::Flush ( )
finalvirtual

Flushes the log data to disk.

Implements wpi::log::DataLog.

◆ operator=() [1/2]

DataLogWriter & wpi::log::DataLogWriter::operator= ( const DataLogWriter &&  )
delete

◆ operator=() [2/2]

DataLogWriter & wpi::log::DataLogWriter::operator= ( const DataLogWriter )
delete

◆ Stop()

void wpi::log::DataLogWriter::Stop ( )
finalvirtual

Stops appending all records to the log, and closes the log file.

Reimplemented from wpi::log::DataLog.


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