]> granicus.if.org Git - pdns/commitdiff
implement getNameWithAddr() for downstreams for pretty log messages
authorbert hubert <bert.hubert@netherlabs.nl>
Mon, 7 Dec 2015 06:51:59 +0000 (07:51 +0100)
committerbert hubert <bert.hubert@netherlabs.nl>
Mon, 7 Dec 2015 06:51:59 +0000 (07:51 +0100)
pdns/dnsdist.cc
pdns/dnsdist.hh

index 9d1a9f0c2b024983c54fb83274159beeca7f3c18..6c46833a05c541a21b57ccdbcb426b7f6116b53d 100644 (file)
@@ -673,7 +673,7 @@ void* maintThread()
       if(dss->availability==DownstreamState::Availability::Auto) {
        bool newState=upCheck(dss->remote, dss->checkName, dss->checkType, dss->mustResolve);
        if(newState != dss->upStatus) {
-         warnlog("Marking downstream %s as '%s'", dss->getName(), newState ? "up" : "down");
+         warnlog("Marking downstream %s as '%s'", dss->getNameWithAddr(), newState ? "up" : "down");
        }
        dss->upStatus = newState;
       }
@@ -697,7 +697,7 @@ void* maintThread()
         }          
       }
     }
-
+    
     std::lock_guard<std::mutex> lock(g_luamutex);
     auto f =g_lua.readVariable<boost::optional<std::function<void()> > >("maintenance");
     if(f)
@@ -754,7 +754,6 @@ try
       else
        response=g_outputBuffer;
 
-
     }
     catch(const LuaContext::ExecutionErrorException& e) {
       response = "Error: " + string(e.what()) + ": ";
@@ -1356,12 +1355,11 @@ try
   for(auto& dss : g_dstates.getCopy()) { // it is a copy, but the internal shared_ptrs are the real deal
     if(dss->availability==DownstreamState::Availability::Auto) {
       bool newState=upCheck(dss->remote, dss->checkName, dss->checkType, dss->mustResolve);
-      warnlog("Marking downstream %s as '%s'", dss->remote.toStringWithPort(), newState ? "up" : "down");
+      warnlog("Marking downstream %s as '%s'", dss->getNameWithAddr(), newState ? "up" : "down");
       dss->upStatus = newState;
     }
   }
 
-
   for(auto& cs : toLaunch) {
     if (cs->udpFD >= 0) {
       thread t1(udpClientThread, cs);
@@ -1373,7 +1371,6 @@ try
     }
   }
 
-
   thread carbonthread(carbonDumpThread);
   carbonthread.detach();
 
index 1aaef1da3d672918eabc7a9236859e5dc7af19f5..f3b71fd319752174f6dce6e65c5f1705a50d687a 100644 (file)
@@ -315,6 +315,13 @@ struct DownstreamState
     }
     return name;
   }
+  string getNameWithAddr() const {
+    if (name.empty()) {
+      return remote.toStringWithPort();
+    }
+    return name + " (" + remote.toStringWithPort()+ ")";
+  }
+
 };
 using servers_t =vector<std::shared_ptr<DownstreamState>>;