Simple Data Logging
data_logging.h
Go to the documentation of this file.
1 // //
3 // Copyright (c) 2016-2018 Leonardo Consoni <consoni_2519@hotmail.com> //
4 // //
5 // This file is part of Simple Data Logging. //
6 // //
7 // Simple Data Logging is free software: you can redistribute it and/or modify //
8 // it under the terms of the GNU Lesser General Public License as published //
9 // by the Free Software Foundation, either version 3 of the License, or //
10 // (at your option) any later version. //
11 // //
12 // Simple Data Logging is distributed in the hope that it will be useful, //
13 // but WITHOUT ANY WARRANTY; without even the implied warranty of //
14 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the //
15 // GNU Lesser General Public License for more details. //
16 // //
17 // You should have received a copy of the GNU Lesser General Public License //
18 // along with Simple Data Logging. If not, see <http://www.gnu.org/licenses/>. //
19 // //
21 
22 
25 
26 
27 #ifndef DATA_LOGGING_H
28 #define DATA_LOGGING_H
29 
30 
31 #include <stddef.h>
32 
33 #define LOG_FILE_PATH_MAX_LENGTH 256
34 #define DATA_LOG_MAX_PRECISION 15
35 
36 #ifdef DEBUG
37  #define DEBUG_PRINT( formatString, ... ) Log_PrintString( NULL, "%s(%d): " formatString, __func__, __LINE__, __VA_ARGS__ )
39 #else
40  #define DEBUG_PRINT( formatString, ... )
41 #endif
42 
43 
44 typedef struct _LogData LogData;
45 typedef LogData* Log;
46 
51 Log Log_Init( const char* logPath, size_t dataPrecision );
52 
55 void Log_End( Log log );
56 
59 void Log_SetDirectory( const char* directoryPath );
60 
63 void Log_SetBaseName( const char* baseName );
64 
69 void Log_RegisterValues( Log log, size_t valuesNumber, ... );
70 
75 void Log_RegisterList( Log log, size_t valuesNumber, double* valuesList );
76 
81 void Log_PrintString( Log log, const char* formatString, ... );
82 
86 void Log_EnterNewLine( Log log, double timeStamp );
87 
88 
89 #endif // DATA_LOGGING_H
void Log_End(Log log)
Deallocate and destroys given data structure.
void Log_SetBaseName(const char *baseName)
Define a common base (folder) name and time stamp for log files.
void Log_PrintString(Log log, const char *formatString,...)
Log custom string.
void Log_SetDirectory(const char *directoryPath)
Overwrite default root file path where logs will be saved.
struct _LogData LogData
Single log internal data structure.
Definition: data_logging.h:44
Log Log_Init(const char *logPath, size_t dataPrecision)
Initialize data logging to terminal or a specific text file.
void Log_RegisterValues(Log log, size_t valuesNumber,...)
Log a numerical values in a variable arguments list format.
LogData * Log
Opaque reference to log internal data structure.
Definition: data_logging.h:45
void Log_RegisterList(Log log, size_t valuesNumber, double *valuesList)
Log a numerical values in a array format.
void Log_EnterNewLine(Log log, double timeStamp)
Enter new log line indexed in time.