WPILibC++ 2025.1.1
Loading...
Searching...
No Matches
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.
 
 DataLogWriter (wpi::Logger &msglog, std::string_view filename, std::error_code &ec, std::string_view extraHeader="")
 Construct with a filename.
 
 DataLogWriter (std::unique_ptr< wpi::raw_ostream > os, std::string_view extraHeader="")
 Constructs with an output stream.
 
 DataLogWriter (wpi::Logger &msglog, std::unique_ptr< wpi::raw_ostream > os, std::string_view extraHeader="")
 Constructs with an output stream.
 
 ~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.
 
void Stop () final
 Stops appending all records to the log, and closes the log file.
 
wpi::raw_ostreamGetStream ()
 Gets the output stream.
 
- 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 Pause ()
 Pauses appending of data records to the log.
 
virtual void Resume ()
 Resumes appending of data records to the log.
 
bool HasSchema (std::string_view name) const
 Returns whether there is a data schema already registered with the given name.
 
void AddSchema (std::string_view name, std::string_view type, std::span< const uint8_t > schema, int64_t timestamp=0)
 Registers a data schema.
 
void AddSchema (std::string_view name, std::string_view type, std::string_view schema, int64_t timestamp=0)
 Registers a data schema.
 
template<ProtobufSerializable T>
void AddProtobufSchema (ProtobufMessage< T > &msg, int64_t timestamp=0)
 Registers a protobuf schema.
 
template<typename T , typename... I>
requires StructSerializable<T, I...>
void AddStructSchema (const I &... info, int64_t timestamp=0)
 Registers a struct schema.
 
int Start (std::string_view name, std::string_view type, std::string_view metadata={}, int64_t timestamp=0)
 Start an entry.
 
void Finish (int entry, int64_t timestamp=0)
 Finish an entry.
 
void SetMetadata (int entry, std::string_view metadata, int64_t timestamp=0)
 Updates the metadata for an entry.
 
void AppendRaw (int entry, std::span< const uint8_t > data, int64_t timestamp)
 Appends a raw record to the log.
 
void AppendRaw2 (int entry, std::span< const std::span< const uint8_t > > data, int64_t timestamp)
 Appends a raw record to the log.
 
void AppendBoolean (int entry, bool value, int64_t timestamp)
 Appends a boolean record to the log.
 
void AppendInteger (int entry, int64_t value, int64_t timestamp)
 Appends an integer record to the log.
 
void AppendFloat (int entry, float value, int64_t timestamp)
 Appends a float record to the log.
 
void AppendDouble (int entry, double value, int64_t timestamp)
 Appends a double record to the log.
 
void AppendString (int entry, std::string_view value, int64_t timestamp)
 Appends a string record to the log.
 
void AppendBooleanArray (int entry, std::span< const bool > arr, int64_t timestamp)
 Appends a boolean array record to the log.
 
void AppendBooleanArray (int entry, std::span< const int > arr, int64_t timestamp)
 Appends a boolean array record to the log.
 
void AppendBooleanArray (int entry, std::span< const uint8_t > arr, int64_t timestamp)
 Appends a boolean array record to the log.
 
void AppendIntegerArray (int entry, std::span< const int64_t > arr, int64_t timestamp)
 Appends an integer array record to the log.
 
void AppendFloatArray (int entry, std::span< const float > arr, int64_t timestamp)
 Appends a float array record to the log.
 
void AppendDoubleArray (int entry, std::span< const double > arr, int64_t timestamp)
 Appends a double array record to the log.
 
void AppendStringArray (int entry, std::span< const std::string > arr, int64_t timestamp)
 Appends a string array record to the log.
 
void AppendStringArray (int entry, std::span< const std::string_view > arr, int64_t timestamp)
 Appends a string array record to the log.
 
void AppendStringArray (int entry, std::span< const struct WPI_String > arr, int64_t timestamp)
 Appends a string array record to the log.
 

Additional Inherited Members

- Protected Member Functions inherited from wpi::log::DataLog
 DataLog (wpi::Logger &msglog, std::string_view extraHeader="")
 Constructs the log.
 
void StartFile ()
 Starts the log.
 
void FlushBufs (std::vector< Buffer > *writeBufs)
 Provides complete set of all buffers that need to be written.
 
void ReleaseBufs (std::vector< Buffer > *bufs)
 Releases memory for a set of buffers back to the internal buffer pool.
 
virtual void BufferHalfFull ()
 Called when internal buffers are half the maximum count.
 
- 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.

◆ GetStream()

wpi::raw_ostream & wpi::log::DataLogWriter::GetStream ( )
inline

Gets the output stream.

Returns
output stream

◆ 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: