From: bert hubert Date: Mon, 7 Dec 2015 06:51:59 +0000 (+0100) Subject: implement getNameWithAddr() for downstreams for pretty log messages X-Git-Tag: dnsdist-1.0.0-alpha1~110 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a7940c06acc79dfdbe827230b18ace936a82335f;p=pdns implement getNameWithAddr() for downstreams for pretty log messages --- diff --git a/pdns/dnsdist.cc b/pdns/dnsdist.cc index 9d1a9f0c2..6c46833a0 100644 --- a/pdns/dnsdist.cc +++ b/pdns/dnsdist.cc @@ -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 lock(g_luamutex); auto f =g_lua.readVariable > >("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(); diff --git a/pdns/dnsdist.hh b/pdns/dnsdist.hh index 1aaef1da3..f3b71fd31 100644 --- a/pdns/dnsdist.hh +++ b/pdns/dnsdist.hh @@ -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>;