forked from anse1/sqlsmith
-
Notifications
You must be signed in to change notification settings - Fork 0
/
log.hh
60 lines (51 loc) · 1.39 KB
/
log.hh
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
50
51
52
53
54
55
56
57
58
59
60
/// @file
/// @brief logging
#ifndef LOG_HH
#define LOG_HH
#include <exception>
#include <pqxx/pqxx>
#include <string>
#include "prod.hh"
#include "dut.hh"
/// logger base class
struct logger {
virtual void generated(prod &query) {(void)query; }
virtual void executed(prod &query) {(void)query; }
virtual void error(prod &query, const dut::failure &e) {
(void)query, (void)e;
}
};
/// logger to dump all generated queries
struct query_dumper : logger {
virtual void generated(prod &query) {
query.out(std::cout);
std::cout << ";" << std::endl;
}
};
/// logger for statistics collection
struct stats_collecting_logger : logger {
long queries = 0;
float sum_nodes = 0;
float sum_height = 0;
float sum_retries = 0;
virtual void generated(prod &query);
};
/// stderr logger
struct cerr_logger : stats_collecting_logger {
const int columns = 80;
std::map<std::string, long> errors;
virtual void report();
virtual void generated(prod &query);
virtual void executed(prod &query);
virtual void error(prod &query, const dut::failure &e);
void report(prod &p);
};
/// logger to postgres database
struct pqxx_logger : stats_collecting_logger {
long id;
std::shared_ptr<pqxx::connection> c;
pqxx_logger(std::string target, std::string conninfo, struct schema &s);
virtual void generated(prod &query);
virtual void error(prod &query, const dut::failure &e);
};
#endif