forked from frontcover/RadarVisual
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtechlogger.cpp
More file actions
49 lines (39 loc) · 1.3 KB
/
Copy pathtechlogger.cpp
File metadata and controls
49 lines (39 loc) · 1.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
#include "techlogger.h"
void TechLogger::dropData(std::condition_variable *cond){
while (true) {
std::mutex mut;
std::unique_lock<std::mutex> lck_cond(mut);
cond->wait_for(lck_cond, std::chrono::milliseconds(500));
std::unique_lock<std::mutex> lck(mutLocal);
std::vector<std::string> dataTemp = std::move(data);
lck.unlock();
if (fileName.isEmpty() && !isRunning)
break;
if (fileName.isEmpty())
continue;
std::string absFileName = strDirPath.toStdString() + fileName.toStdString();
absFileName += ".log";
if(!strDirPath.isEmpty() && dataTemp.size() != 0){
std::ofstream fstr(absFileName, std::ios::app);
if(fstr.is_open()){
for(const auto &ln : dataTemp)
fstr << ln;
fstr.close();
}
}
if(!isRunning)
break;
}
}
void TechLogger::updFileName(const QString &name){
fileName = name;
QDateTime qdt = QDateTime::currentDateTime();
QString _date = qdt.date().toString("yyyy-MM-dd");
QString _time = qdt.time().toString("hh-mm-ss");
fileName += _date;
fileName += "_";
fileName += _time;
}
void TechLogger::addSymb(const QString &symb){
fileName += "_" + symb;
}