#include "paxos.h"
#include <fstream>
#include <iostream>
+#include "tprintf.h"
// Paxos must maintain some durable state (i.e., that survives power
// failures) to run Paxos correct. This module implements a log with
unsigned instance;
from.open(name.c_str());
- printf ("logread\n");
+ LOG("logread");
while (from >> type) {
if (type == "done") {
std::string v;
getline(from, v);
pxs->values[instance] = v;
pxs->instance_h = instance;
- printf ("logread: instance: %d w. v = %s\n", instance,
- pxs->values[instance].c_str());
+ LOG("logread: instance: " << instance << " w. v = " <<
+ pxs->values[instance]);
pxs->v_a.clear();
pxs->n_h.n = 0;
pxs->n_a.n = 0;
} else if (type == "propseen") {
from >> pxs->n_h.n;
from >> pxs->n_h.m;
- printf("logread: high update: %d(%s)\n", pxs->n_h.n, pxs->n_h.m.c_str());
+ LOG("logread: high update: " << pxs->n_h.n << "(" << pxs->n_h.m << ")");
} else if (type == "accepted") {
std::string v;
from >> pxs->n_a.n;
from.get();
getline(from, v);
pxs->v_a = v;
- printf("logread: prop update %d(%s) with v = %s\n", pxs->n_a.n,
- pxs->n_a.m.c_str(), pxs->v_a.c_str());
+ LOG("logread: prop update " << pxs->n_a.n << "(" << pxs->n_a.m << ") with v = " << pxs->v_a);
} else {
- printf("logread: unknown log record\n");
+ LOG("logread: unknown log record");
VERIFY(0);
}
}
log::restore(std::string s)
{
std::ofstream f;
- printf("restore: %s\n", s.c_str());
+ LOG("restore: " << s);
f.open(name.c_str(), std::ios::trunc);
f << s;
f.close();