Rewrote threaded log code to be more idiomatic.
[invirt/third/libt4.git] / rsm_client.cc
index 598a1ed..d047f8b 100644 (file)
@@ -4,10 +4,10 @@
 #include <unistd.h>
 
 rsm_client::rsm_client(string dst) : primary(dst) {
-    LOG("create rsm_client");
+    LOG << "create rsm_client";
     lock ml(rsm_client_mutex);
     VERIFY (init_members(ml));
-    LOG("done");
+    LOG << "done";
 }
 
 void rsm_client::primary_failure(lock &) {
@@ -18,7 +18,7 @@ void rsm_client::primary_failure(lock &) {
 rsm_protocol::status rsm_client::invoke(unsigned int proc, string & rep, const string & req) {
     lock ml(rsm_client_mutex);
     while (1) {
-        LOG("proc " << hex << proc << " primary " << primary);
+        LOG << "proc " << hex << proc << " primary " << primary;
         handle h(primary);
 
         ml.unlock();
@@ -31,28 +31,28 @@ rsm_protocol::status rsm_client::invoke(unsigned int proc, string & rep, const s
         if (!cl)
             goto prim_fail;
 
-        LOG("proc " << hex << proc << " primary " << primary << " ret " << dec << ret);
+        LOG << "proc " << hex << proc << " primary " << primary << " ret " << dec << ret;
         if (ret == rsm_client_protocol::OK)
             return rsm_protocol::OK;
         if (ret == rsm_client_protocol::BUSY) {
-            LOG("rsm is busy " << primary);
+            LOG << "rsm is busy " << primary;
             usleep(300000);
             continue;
         }
         if (ret == rsm_client_protocol::NOTPRIMARY) {
-            LOG("primary " << primary << " isn't the primary--let's get a complete list of mems");
+            LOG << "primary " << primary << " isn't the primary--let's get a complete list of mems";
             if (init_members(ml))
                 continue;
         }
 prim_fail:
-        LOG("primary " << primary << " failed ret " << dec << ret);
+        LOG << "primary " << primary << " failed ret " << dec << ret;
         primary_failure(ml);
-        LOG("retry new primary " << primary);
+        LOG << "retry new primary " << primary;
     }
 }
 
 bool rsm_client::init_members(lock & rsm_client_mutex_lock) {
-    LOG("get members!");
+    LOG << "get members!";
     handle h(primary);
     int ret = rsm_client_protocol::ERR;
     rpcc *cl;
@@ -66,14 +66,14 @@ bool rsm_client::init_members(lock & rsm_client_mutex_lock) {
     if (cl == 0 || ret != rsm_protocol::OK)
         return false;
     if (known_mems.size() < 1) {
-        LOG("do not know any members!");
+        LOG << "do not know any members!";
         VERIFY(0);
     }
 
     primary = known_mems.back();
     known_mems.pop_back();
 
-    LOG("primary " << primary);
+    LOG << "primary " << primary;
 
     return true;
 }