[wpiutil] Add C API for DataLog (#5509)

This commit is contained in:
Peter Johnson
2023-08-06 20:18:50 -07:00
committed by GitHub
parent b5bd0771eb
commit c01814b80e
5 changed files with 541 additions and 1 deletions

View File

@@ -588,6 +588,27 @@ void NT_SetNow(int64_t timestamp) {
nt::SetNow(timestamp);
}
NT_DataLogger NT_StartEntryDataLog(NT_Inst inst, struct WPI_DataLog* log,
const char* prefix, const char* logPrefix) {
return nt::StartEntryDataLog(inst, *reinterpret_cast<wpi::log::DataLog*>(log),
prefix, logPrefix);
}
void NT_StopEntryDataLog(NT_DataLogger logger) {
nt::StopEntryDataLog(logger);
}
NT_ConnectionDataLogger NT_StartConnectionDataLog(NT_Inst inst,
struct WPI_DataLog* log,
const char* name) {
return nt::StartConnectionDataLog(
inst, *reinterpret_cast<wpi::log::DataLog*>(log), name);
}
void NT_StopConnectionDataLog(NT_ConnectionDataLogger logger) {
nt::StopConnectionDataLog(logger);
}
NT_Listener NT_AddLogger(NT_Inst inst, unsigned int min_level,
unsigned int max_level, void* data,
NT_ListenerCallback func) {

View File

@@ -16,6 +16,8 @@
extern "C" {
#endif
struct WPI_DataLog;
/**
* @defgroup ntcore_c_api ntcore C API
*
@@ -1347,6 +1349,54 @@ void NT_SetNow(int64_t timestamp);
/** @} */
/**
* @defgroup ntcore_data_logger_cfunc Data Logger Functions
* @{
*/
/**
* Starts logging entry changes to a DataLog.
*
* @param inst instance handle
* @param log data log object; lifetime must extend until StopEntryDataLog is
* called or the instance is destroyed
* @param prefix only store entries with names that start with this prefix;
* the prefix is not included in the data log entry name
* @param logPrefix prefix to add to data log entry names
* @return Data logger handle
*/
NT_DataLogger NT_StartEntryDataLog(NT_Inst inst, struct WPI_DataLog* log,
const char* prefix, const char* logPrefix);
/**
* Stops logging entry changes to a DataLog.
*
* @param logger data logger handle
*/
void NT_StopEntryDataLog(NT_DataLogger logger);
/**
* Starts logging connection changes to a DataLog.
*
* @param inst instance handle
* @param log data log object; lifetime must extend until StopConnectionDataLog
* is called or the instance is destroyed
* @param name data log entry name
* @return Data logger handle
*/
NT_ConnectionDataLogger NT_StartConnectionDataLog(NT_Inst inst,
struct WPI_DataLog* log,
const char* name);
/**
* Stops logging connection changes to a DataLog.
*
* @param logger data logger handle
*/
void NT_StopConnectionDataLog(NT_ConnectionDataLogger logger);
/** @} */
/**
* @defgroup ntcore_logger_cfunc Logger Functions
* @{