mirror of
https://github.com/jomjol/AI-on-the-edge-device.git
synced 2025-12-10 13:36:54 +03:00
Initial Code v0.1.0
This commit is contained in:
41
code/lib/jomjol_logfile/ClassLogFile.cpp
Normal file
41
code/lib/jomjol_logfile/ClassLogFile.cpp
Normal file
@@ -0,0 +1,41 @@
|
||||
#include "ClassLogFile.h"
|
||||
#include "time_sntp.h"
|
||||
|
||||
ClassLogFile LogFile("/sdcard/log.txt");
|
||||
|
||||
void ClassLogFile::WriteToFile(std::string info, bool _time)
|
||||
{
|
||||
FILE* pFile;
|
||||
std::string zwtime;
|
||||
|
||||
|
||||
pFile = fopen(logfile.c_str(), "a+");
|
||||
|
||||
if (_time)
|
||||
{
|
||||
time_t rawtime;
|
||||
struct tm* timeinfo;
|
||||
char buffer[80];
|
||||
|
||||
time(&rawtime);
|
||||
timeinfo = localtime(&rawtime);
|
||||
|
||||
strftime(buffer, 80, "%Y-%m-%d_%H-%M-%S", timeinfo);
|
||||
|
||||
zwtime = std::string(buffer);
|
||||
info = zwtime + ": " + info;
|
||||
}
|
||||
fputs(info.c_str(), pFile);
|
||||
fputs("\n", pFile);
|
||||
|
||||
fclose(pFile);
|
||||
}
|
||||
|
||||
ClassLogFile::ClassLogFile(std::string _logfile)
|
||||
{
|
||||
logfile = _logfile;
|
||||
}
|
||||
|
||||
ClassLogFile::~ClassLogFile()
|
||||
{
|
||||
}
|
||||
17
code/lib/jomjol_logfile/ClassLogFile.h
Normal file
17
code/lib/jomjol_logfile/ClassLogFile.h
Normal file
@@ -0,0 +1,17 @@
|
||||
|
||||
#include <string>
|
||||
|
||||
|
||||
class ClassLogFile
|
||||
{
|
||||
private:
|
||||
/* data */
|
||||
std::string logfile;
|
||||
public:
|
||||
ClassLogFile(std::string _logfile);
|
||||
~ClassLogFile();
|
||||
|
||||
void WriteToFile(std::string info, bool _time = true);
|
||||
};
|
||||
|
||||
extern ClassLogFile LogFile;
|
||||
Reference in New Issue
Block a user