change logging for navcat

pull/125/head
bert hubert 2020-07-03 21:34:53 +02:00
parent df151901c4
commit 199679f87a
1 changed files with 7 additions and 3 deletions

View File

@ -86,7 +86,9 @@ void sendProtobuf(string_view dir, time_t startTime, time_t stopTime=0)
// so we have a ton of files, and internally these are not ordered // so we have a ton of files, and internally these are not ordered
map<string,uint32_t> fpos; map<string,uint32_t> fpos;
vector<pair<timespec,string> > rnmms; vector<pair<timespec,string> > rnmms;
for(;;) { for(;;) {
cerr<<"Gathering data"<<endl;
auto srcs = getSources(dir); auto srcs = getSources(dir);
rnmms.clear(); rnmms.clear();
for(const auto& src: srcs) { for(const auto& src: srcs) {
@ -100,7 +102,7 @@ void sendProtobuf(string_view dir, time_t startTime, time_t stopTime=0)
fclose(fp); fclose(fp);
continue; continue;
} }
cerr <<"Seeked to position "<<fpos[fname]<<" of "<<fname<<endl; // cerr <<"Seeked to position "<<fpos[fname]<<" of "<<fname<<endl;
uint32_t looked=0; uint32_t looked=0;
string msg; string msg;
@ -112,17 +114,18 @@ void sendProtobuf(string_view dir, time_t startTime, time_t stopTime=0)
} }
++looked; ++looked;
} }
cerr<<"Harvested "<<rnmms.size()<<" events out of "<<looked<<endl; // cerr<<"Harvested "<<rnmms.size()<<" events out of "<<looked<<endl;
fpos[fname]=offset; fpos[fname]=offset;
fclose(fp); fclose(fp);
} }
cerr<<"Sorting data"<<endl;
sort(rnmms.begin(), rnmms.end(), [](const auto& a, const auto& b) sort(rnmms.begin(), rnmms.end(), [](const auto& a, const auto& b)
{ {
return std::tie(a.first.tv_sec, a.first.tv_nsec) return std::tie(a.first.tv_sec, a.first.tv_nsec)
< std::tie(b.first.tv_sec, b.first.tv_nsec); < std::tie(b.first.tv_sec, b.first.tv_nsec);
}); });
cerr<<"Sending data"<<endl;
for(const auto& nmm: rnmms) { for(const auto& nmm: rnmms) {
if(nmm.first.tv_sec > stopTime) if(nmm.first.tv_sec > stopTime)
break; break;
@ -133,6 +136,7 @@ void sendProtobuf(string_view dir, time_t startTime, time_t stopTime=0)
//fwrite(buf.c_str(), 1, buf.size(), stdout); //fwrite(buf.c_str(), 1, buf.size(), stdout);
writen2(1, buf.c_str(), buf.size()); writen2(1, buf.c_str(), buf.size());
} }
cerr<<"Done sending"<<endl;
if(3600 + start.tv_sec - (start.tv_sec%3600) < stopTime) if(3600 + start.tv_sec - (start.tv_sec%3600) < stopTime)
start.tv_sec = 3600 + start.tv_sec - (start.tv_sec%3600); start.tv_sec = 3600 + start.tv_sec - (start.tv_sec%3600);
else { else {