From: Pieter Lexis Date: Thu, 12 Apr 2018 15:07:19 +0000 (+0200) Subject: ixfrdist: use the logging module X-Git-Tag: dnsdist-1.3.1~148^2~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1361013ea8a4071ac012e7889852cfe27ee01f4a;p=thirdparty%2Fpdns.git ixfrdist: use the logging module --- diff --git a/pdns/Makefile.am b/pdns/Makefile.am index ab2f39874f..981849ab8a 100644 --- a/pdns/Makefile.am +++ b/pdns/Makefile.am @@ -616,7 +616,7 @@ ixfrdist_SOURCES = \ ixfr.cc ixfr.hh \ ixfrdist.cc \ ixfrutils.cc ixfrutils.hh \ - logger.cc \ + logger.cc logger.hh\ misc.cc misc.hh \ mplexer.hh \ nsecrecords.cc \ diff --git a/pdns/ixfrdist.cc b/pdns/ixfrdist.cc index 6a76b0e684..5285bf5089 100644 --- a/pdns/ixfrdist.cc +++ b/pdns/ixfrdist.cc @@ -41,6 +41,7 @@ #include "mplexer.hh" #include "misc.hh" #include "iputils.hh" +#include "logger.hh" /* BEGIN Needed because of deeper dependencies */ #include "arguments.hh" @@ -77,9 +78,6 @@ po::variables_map g_vm; string g_workdir; ComboAddress g_master; -bool g_verbose = false; -bool g_debug = false; - bool g_exiting = false; #define KEEP_DEFAULT 20 @@ -91,18 +89,12 @@ uint16_t g_axfrTimeout = AXFRTIMEOUT_DEFAULT; NetmaskGroup g_acl; void handleSignal(int signum) { - if (g_verbose) { - cerr<<"[INFO] Got "<d_name)); } closedir(dp); - if (g_verbose) { - cerr<<"[INFO] Found "< guard(g_soas_mutex); for (auto iter = zoneVersions.cbegin(); iter != zoneVersions.cend() - g_keep; ++iter) { string fname = dir + "/" + std::to_string(*iter); - if (g_debug) { - cerr<<"[DEBUG] Removing "< soa; { @@ -213,33 +195,26 @@ void updateThread() { g_soas[domain].soa = soa; } if (soa != nullptr) { - if (g_verbose) { - cerr<<"[INFO] Loaded zone "<d_st.serial<d_st.serial< sr; try { lastCheck[domain] = now; auto newSerial = getSerialFromMaster(g_master, domain, sr); // TODO TSIG if(current_soa != nullptr) { - if (g_verbose) { - cerr<<"[INFO] Got SOA Serial for "<d_st.serial; - } + g_log<d_st.serial; if (newSerial == current_soa->d_st.serial) { - if (g_verbose) { - cerr<<", not updating."<d_st.serial<<" to "<d_st.serial<<" to "< guard(g_soas_mutex); ixfrdiff_t diff; @@ -340,9 +301,9 @@ void updateThread() { g_soas[domain].soa = soa; } } catch (PDNSException &e) { - cerr<<"[WARNING] Could not retrieve AXFR for '"< info_msg; - if (g_debug) { - cerr<<"[DEBUG] Had "< } if (toSend.empty()) { - cerr<<"[WARNING] No IXFR available from serial "<d_st.serial<<" for zone "<d_st.serial<<" for zone "< lk(g_tcpRequestFDsMutex); g_tcpHandlerCV.wait(lk, []{return g_tcpRequestFDs.size() || g_exiting ;}); if (g_exiting) { - if (g_debug) { - cerr<<"[DEBUG] "<(sizeof(buf))); res = readn2WithTimeout(cfd, &buf, toRead, 2); + g_log< 0 || g_vm.count("debug") > 0) { - g_verbose = true; + if (g_vm.count("verbose")) { + g_log.setLoglevel(Logger::Info); + g_log.toConsole(Logger::Info); } if (g_vm.count("debug") > 0) { - g_debug = true; + g_log.setLoglevel(Logger::Debug); + g_log.toConsole(Logger::Debug); } if (g_vm.count("keep") > 0) { @@ -828,7 +788,7 @@ int main(int argc, char** argv) { try { listen_addresses.push_back(ComboAddress(addr, 53)); } catch(PDNSException &e) { - cerr<<"[ERROR] listen-address '"<(), 53); } catch(PDNSException &e) { - cerr<<"[ERROR] server-address '"<()<<"' is not an IP address: "<()<<"' is not an IP address: "<>()) { try { g_domains.insert(DNSName(domain)); } catch (PDNSException &e) { - cerr<<"[ERROR] '"< allSockets; for (const auto& addr : listen_addresses) { @@ -891,7 +849,7 @@ int main(int argc, char** argv) { g_fdm->addReadFD(s, stype == SOCK_DGRAM ? handleUDPRequest : handleTCPRequest); allSockets.insert(s); } catch(runtime_error &e) { - cerr<<"[ERROR] "<gr_gid; } } - if(g_verbose) { - cerr<<"[INFO] Dropping effective group-id to "<pw_uid; @@ -939,21 +895,19 @@ int main(int argc, char** argv) { struct passwd *pw = getpwuid(newuid); if (pw == nullptr) { if (setgroups(0, nullptr) < 0) { - cerr<<"[ERROR] Unable to drop supplementary gids: "<pw_name, newgid) < 0) { - cerr<<"[ERROR] Unable to set supplementary groups: "<pw_uid) < 0) { - cerr<<"[ERROR] Could not set user id to "<()]; @@ -988,26 +942,22 @@ int main(int argc, char** argv) { gettimeofday(&now, 0); g_fdm->run(&now); if (g_exiting) { - if (g_verbose) { - cerr<<"[INFO] Shutting down!"<(); i++) { tcpHandlers[i].join(); } - if (g_verbose) { - cerr<<"[INFO] IXFR distributor stopped"<