forked from UBC-Thunderbots/Software
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcsv_sink.cpp
More file actions
24 lines (20 loc) · 802 Bytes
/
csv_sink.cpp
File metadata and controls
24 lines (20 loc) · 802 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#include "software/logger/csv_sink.h"
#include "compat_flags.h"
CSVSink::CSVSink(const std::string& log_directory) : log_directory(log_directory) {}
void CSVSink::appendToFile(g3::LogMessageMover log_entry)
{
if (log_entry.get()._level.value == CSV.value)
{
std::string msg = log_entry.get()._message;
size_t pos = msg.find(file_ext) + file_ext.length();
if (pos != std::string::npos + file_ext.length())
{
std::string file_name = msg.substr(0, pos);
std::string file_data = msg.substr(pos, msg.length());
std::ofstream csv_file(log_directory + "/" + file_name,
std::ios::out | std::ios_base::app);
csv_file << file_data;
csv_file.close();
}
}
}