X-Git-Url: http://xvm.mit.edu/gitweb/invirt/third/libt4.git/blobdiff_plain/5d99dbf06a14904944f5593c63705934bdfdcfb7..e0c49ff6ba44cf5b47ab91d58b67763f5a1c7a58:/log.cc?ds=sidebyside diff --git a/log.cc b/log.cc index 3b881fa..decb827 100644 --- a/log.cc +++ b/log.cc @@ -12,11 +12,11 @@ log::log(proposer_acceptor *_acc, string _me) : pxs (_acc) { } void log::logread(void) { - ifstream from(name); + std::ifstream from(name); string type; unsigned instance; - LOG("logread"); + LOG << "logread"; while (from >> type) { if (type == "done") { string v; @@ -25,23 +25,23 @@ void log::logread(void) { getline(from, v); pxs->values[instance] = v; pxs->instance_h = instance; - LOG("logread: instance: " << instance << " w. v = " << - pxs->values[instance]); + LOG << "logread: instance: " << instance << " w. v = " + << pxs->values[instance]; pxs->accepted_value.clear(); pxs->promise.n = 0; pxs->accepted.n = 0; } else if (type == "propseen") { from >> pxs->promise.n >> pxs->promise.m; - LOG("logread: high update: " << pxs->promise.n << "(" << pxs->promise.m << ")"); + LOG << "logread: high update: " << pxs->promise.n << "(" << pxs->promise.m << ")"; } else if (type == "accepted") { string v; from >> pxs->accepted.n >> pxs->accepted.m; from.get(); getline(from, v); pxs->accepted_value = v; - LOG("logread: prop update " << pxs->accepted.n << "(" << pxs->accepted.m << ") with v = " << pxs->accepted_value); + LOG << "logread: prop update " << pxs->accepted.n << "(" << pxs->accepted.m << ") with v = " << pxs->accepted_value; } else { - LOG("logread: unknown log record"); + LOG << "logread: unknown log record"; VERIFY(0); } } @@ -49,25 +49,25 @@ void log::logread(void) { } string log::dump() { - ifstream from(name); + std::ifstream from(name); string res; string v; - while (getline(from, v)) + while (std::getline(from, v)) res += v + "\n"; from.close(); return res; } void log::restore(string s) { - LOG("restore: " << s); - ofstream f(name, ios::trunc); + LOG << "restore: " << s; + std::ofstream f(name, std::ios::trunc); f << s; f.close(); } // XXX should be an atomic operation void log::loginstance(unsigned instance, string v) { - ofstream f(name, ios::app); + std::ofstream f(name, std::ios::app); f << "done " << instance << " " << v << "\n"; f.close(); } @@ -75,7 +75,7 @@ void log::loginstance(unsigned instance, string v) { // an acceptor should call logprop(promise) when it // receives a prepare to which it responds prepare_ok(). void log::logprop(prop_t promise) { - ofstream f(name, ios::app); + std::ofstream f(name, std::ios::app); f << "propseen " << promise.n << " " << promise.m << "\n"; f.close(); } @@ -83,7 +83,7 @@ void log::logprop(prop_t promise) { // an acceptor should call logaccept(accepted, accepted_value) when it // receives an accept RPC to which it replies accept_ok(). void log::logaccept(prop_t n, string v) { - ofstream f(name, ios::app); + std::ofstream f(name, std::ios::app); f << "accepted " << n.n << " " << n.m << " " << v << "\n"; f.close(); }