| 130 | } |
| 131 | |
| 132 | pqxx_logger::pqxx_logger(std::string target, std::string conninfo, struct schema &s) |
| 133 | { |
| 134 | c = make_shared<pqxx::connection>(conninfo); |
| 135 | |
| 136 | work w(*c); |
| 137 | w.exec("set application_name to '" PACKAGE "::log';"); |
| 138 | |
| 139 | c->prepare("instance", |
| 140 | "insert into instance (rev, target, hostname, version, seed) " |
| 141 | "values ($1, $2, $3, $4, $5) returning id"); |
| 142 | |
| 143 | char hostname[1024]; |
| 144 | gethostname(hostname, sizeof(hostname)); |
| 145 | |
| 146 | ostringstream seed; |
| 147 | seed << smith::rng; |
| 148 | |
| 149 | #if defined(HAVE_LIBPQXX7) || defined(HAVE_LIBPQXX8) |
| 150 | result r = w.exec_prepared("instance", GITREV, target, hostname, s.version, seed.str()); |
| 151 | #else |
| 152 | result r = w.prepared("instance")(GITREV)(target)(hostname)(s.version)(seed.str()).exec(); |
| 153 | #endif |
| 154 | |
| 155 | id = r[0][0].as<long>(id); |
| 156 | |
| 157 | c->prepare("error", |
| 158 | "insert into error (id, msg, query, sqlstate) " |
| 159 | "values (" + to_string(id) + ", $1, $2, $3)"); |
| 160 | |
| 161 | w.exec("insert into stat (id) values (" + to_string(id) + ")"); |
| 162 | c->prepare("stat", |
| 163 | "update stat set generated=$1, level=$2, nodes=$3, updated=now() " |
| 164 | ", retries = $4, impedance = $5 " |
| 165 | "where id = " + to_string(id)); |
| 166 | |
| 167 | w.commit(); |
| 168 | |
| 169 | } |
| 170 | |
| 171 | void pqxx_logger::error(prod &query, const dut::failure &e) |
| 172 | { |
nothing calls this directly
no outgoing calls
no test coverage detected