#include #include #include #include #include #include #include #include #include "dbc.h" using namespace std; using namespace fmt; int main() { try { regex err_re("(.*?):([0-9]+):([0-9]+):\\s*(.*?):\\s*(.*)"); string line; smatch err; ofstream stats_out; stats_out.open("stats.csv", ios::out | ios::app); auto t = time(nullptr); auto tm = *std::gmtime(&t); dbc::check(stats_out.good(), "Error opening stats.csv file."); dbc::pre("simple test", [&]() { return stats_out.good(); }); while(getline(cin, line)) { print("{}\n", line); if(regex_match(line, err, err_re)) { string file_name = err[1].str(); string line = err[2].str(); string col = err[3].str(); string type = err[4].str(); string message = err[5].str(); stats_out << put_time(&tm, "%FT%TZ"); stats_out << format(",{},{},{},{},{}\n", file_name, line, col, type, message); } } stats_out.close(); dbc::post("a post test", [&]() { return !stats_out.is_open(); }); return 0; } catch(dbc::Error &err) { print("ERROR: {}\n", err.message); return 1; } }