Cleanups
[invirt/third/libt4.git] / log.cc
diff --git a/log.cc b/log.cc
index a760815..baf3c2f 100644 (file)
--- a/log.cc
+++ b/log.cc
@@ -1,6 +1,7 @@
 #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
@@ -22,7 +23,7 @@ log::logread(void)
   unsigned instance;
 
   from.open(name.c_str());
-  printf ("logread\n");
+  LOG("logread");
   while (from >> type) {
     if (type == "done") {
       std::string v;
@@ -31,15 +32,15 @@ log::logread(void)
       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;
@@ -47,10 +48,9 @@ log::logread(void)
       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);
     }
   } 
@@ -75,7 +75,7 @@ void
 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();