log
///////////////////////////////////////////////////////
#include <sys/time.h>
#include <cstdio>
#include <cstdlib>
void recordData(char* buf)
{
static FILE* m_pFile = NULL;
bool m_bRecordFile = true;
if (m_bRecordFile)
{
time_t rawTime;
time(&rawTime);
if (!m_pFile)
{
// time_t rawTime;
// time(&rawTime);
char ArmFile[50];
char ArmtimeStr[50];
strftime(ArmtimeStr, 30, "Endo%Y%m%d%H%M%S.txt", localtime(&rawTime));
memcpy(ArmFile, ArmtimeStr, 50);
m_pFile = fopen(ArmFile, "wt+");
if (m_pFile == NULL)
{
printf("Debug File Endo Arm Create Failed\n");
return;
}
fprintf(m_pFile, "Start:\n");
fflush(m_pFile);
}
char ArmtimeStr[50];
strftime(ArmtimeStr, 30, "%Y%m%d%H%M%S:", localtime(&rawTime));
fprintf(m_pFile, ArmtimeStr);
fprintf(m_pFile, buf);
fflush(m_pFile);
}
else
{
if (m_pFile)
{
fclose(m_pFile);
m_pFile = NULL;
}
}
}
// struct timeval tv;
// gettimeofday(&tv,NULL);
// char buf[255] = {0};
// sprintf(buf, "%d\n", tv.tv_sec*1000000 + tv.tv_usec);
// recordData(buf);

浙公网安备 33010602011771号