Simple Data Logging
Macros | Typedefs | Functions
data_logging.h File Reference

Functions for logging/registering data over time to a text file or terminal. More...

#include <stddef.h>

Go to the source code of this file.

Macros

#define LOG_FILE_PATH_MAX_LENGTH   256
 Maximum length of log file (inside data structure) absolute path string.
 
#define DATA_LOG_MAX_PRECISION   15
 Maximum decimal precision for numerical data in a log.
 
#define DEBUG_PRINT(formatString, ...)
 

Typedefs

typedef struct _LogData LogData
 Single log internal data structure.
 
typedef LogDataLog
 Opaque reference to log internal data structure.
 

Functions

Log Log_Init (const char *logPath, size_t dataPrecision)
 Initialize data logging to terminal or a specific text file. More...
 
void Log_End (Log log)
 Deallocate and destroys given data structure. More...
 
void Log_SetDirectory (const char *directoryPath)
 Overwrite default root file path where logs will be saved. More...
 
void Log_SetBaseName (const char *baseName)
 Define a common base (folder) name and time stamp for log files. More...
 
void Log_RegisterValues (Log log, size_t valuesNumber,...)
 Log a numerical values in a variable arguments list format. More...
 
void Log_RegisterList (Log log, size_t valuesNumber, double *valuesList)
 Log a numerical values in a array format. More...
 
void Log_PrintString (Log log, const char *formatString,...)
 Log custom string. More...
 
void Log_EnterNewLine (Log log, double timeStamp)
 Enter new log line indexed in time. More...
 

Detailed Description

Functions for logging/registering data over time to a text file or terminal.

Function Documentation

◆ Log_End()

void Log_End ( Log  log)

Deallocate and destroys given data structure.

Parameters
[in]logreference to log profile

◆ Log_EnterNewLine()

void Log_EnterNewLine ( Log  log,
double  timeStamp 
)

Enter new log line indexed in time.

Parameters
[in]logreference to log profile
[in]timeStampprovided time index/stamp for new log line

◆ Log_Init()

Log Log_Init ( const char *  logPath,
size_t  dataPrecision 
)

Initialize data logging to terminal or a specific text file.

Parameters
[in]logPathpath (from base one) to log file or empty string for terminal logging
[in]dataPrecisiondecimal precision for numerical data in this log
Returns
reference/pointer to created log profile structure (NULL on errors)

◆ Log_PrintString()

void Log_PrintString ( Log  log,
const char *  formatString,
  ... 
)

Log custom string.

Parameters
[in]logreference to log profile
[in]formatStringformat string (like in printf) to list of values
[in]...variable list of values/arguments to be formatted (like in printf)

◆ Log_RegisterList()

void Log_RegisterList ( Log  log,
size_t  valuesNumber,
double *  valuesList 
)

Log a numerical values in a array format.

Parameters
[in]logreference to log profile
[in]valuesNumbernumber of values being logged
[in]...array/pointer of numerical values to be logged

◆ Log_RegisterValues()

void Log_RegisterValues ( Log  log,
size_t  valuesNumber,
  ... 
)

Log a numerical values in a variable arguments list format.

Parameters
[in]logreference to log profile
[in]valuesNumbernumber of values being logged
[in]...variable list of numerical values to be logged

◆ Log_SetBaseName()

void Log_SetBaseName ( const char *  baseName)

Define a common base (folder) name and time stamp for log files.

Parameters
[in]baseNamename of the folder (inside root path) where new logs will be saved, with current time stamp

◆ Log_SetDirectory()

void Log_SetDirectory ( const char *  directoryPath)

Overwrite default root file path where logs will be saved.

Parameters
[in]directoryPathpath (absolute or relative) to desired root directory