Files
Cnomicon/include/libnet++/LogData.h
2021-01-22 10:16:20 -05:00

92 lines
1.8 KiB
C++

//
// GPS Daemon
// Neal Probert
//
/* prevent multiple inclusions */
#ifndef __LogData__
#define __LogData__
/* includes *****************************************************************/
#include <stdarg.h>
#include <syslog.h>
#include "UdpClient.h"
#ifdef MYSQL_LOGGING
#include "mysql/mysql.h"
#endif
#ifdef BZIP2_LOGGING
#include "bzlib.h"
#endif
/* defines ******************************************************************/
#define LOGD_PORT "2940"
/* macros *******************************************************************/
/* structs & typedefs *******************************************************/
/* c class definitions ******************************************************/
//
// Uses the Peak Systems CAN Linux driver and Nissan CAN data
//
class LogData : public UdpClient {
// public data
public:
// private data
private:
// MySQL logging
int nfields;
char myfields[2048];
FILE *pFile;
#ifdef MYSQL_LOGGING
MYSQL *myconn;
char mytable[256];
MYSQL_RES *myres;
#endif
long nrecords;
// formats
bool m_logging;
bool m_syslog;
bool m_binary;
// static data
// public methods
public:
// constructors
LogData();
// destructor
virtual ~LogData();
// public methods
FILE *LogOpen( const char *log = NULL, int bz2=0 );
int LogRead( timeval *tv, char *buf, int max );
int LogPrintf( const char *fmt, ... );
int LogWrite( const char *buf, int max );
void LogClose( void );
void LogRotate( void );
// text only csv logging
void LogFields( const char *flds );
int CsvSplit( char *buf, char *field[], int max );
// logging control
bool IsLogging(void) {return m_logging;};
void SetBinary(void) { m_binary=true; };
// static methods
// private methods
private:
};
#endif