1 | /// @file |
2 | /// @brief logging |
3 | |
4 | #ifndef LOG_HH |
5 | #define LOG_HH |
6 | |
7 | #include <exception> |
8 | #include <map> |
9 | #include <string> |
10 | |
11 | #include "dut.hh" |
12 | #include "prod.hh" |
13 | |
14 | /// logger base class |
15 | struct logger { |
16 | virtual void generated(prod &query) { |
17 | (void)query; |
18 | } |
19 | virtual void executed(prod &query) { |
20 | (void)query; |
21 | } |
22 | virtual void error(prod &query, const dut::failure &e) { |
23 | (void)query, (void)e; |
24 | } |
25 | }; |
26 | |
27 | /// logger to dump all generated queries |
28 | struct query_dumper : logger { |
29 | virtual void generated(prod &query) { |
30 | query.out(std::cout); |
31 | std::cout << ";" << std::endl; |
32 | } |
33 | }; |
34 | |
35 | /// logger for statistics collection |
36 | struct stats_collecting_logger : logger { |
37 | long queries = 0; |
38 | float sum_nodes = 0; |
39 | float sum_height = 0; |
40 | float sum_retries = 0; |
41 | virtual void generated(prod &query); |
42 | }; |
43 | |
44 | /// stderr logger |
45 | struct cerr_logger : stats_collecting_logger { |
46 | const int columns = 80; |
47 | std::map<std::string, long> errors; |
48 | virtual void report(); |
49 | virtual void generated(prod &query); |
50 | virtual void executed(prod &query); |
51 | virtual void error(prod &query, const dut::failure &e); |
52 | void report(prod &p); |
53 | }; |
54 | |
55 | #endif |
56 | |