]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Also refactor code conditional on g_slogStructured
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Wed, 20 Aug 2025 11:34:23 +0000 (13:34 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Wed, 20 Aug 2025 11:34:23 +0000 (13:34 +0200)
Signed-off-by: Otto Moerbeek <otto.moerbeek@open-xchange.com>
pdns/recursordist/pdns_recursor.cc
pdns/recursordist/rec-main.cc
pdns/recursordist/reczones.cc

index a508866564a8fcf3242042ce69e54f499ea72819..68387ed048a5de29dd8009fa3b8c69e6a12371b0 100644 (file)
@@ -1186,17 +1186,7 @@ void startDoResolve(void* arg) // NOLINT(readability-function-cognitive-complexi
     }
 
     if (!g_quiet || tracedQuery) {
-      if (!g_slogStructured) {
-        g_log << Logger::Warning << RecThreadInfo::thread_local_id() << " [" << g_multiTasker->getTid() << "/" << g_multiTasker->numProcesses() << "] " << (comboWriter->d_tcp ? "TCP " : "") << "question for '" << comboWriter->d_mdp.d_qname << "|"
-              << QType(comboWriter->d_mdp.d_qtype) << "' from " << comboWriter->getRemote();
-        if (!comboWriter->d_ednssubnet.getSource().empty()) {
-          g_log << " (ecs " << comboWriter->d_ednssubnet.getSource().toString() << ")";
-        }
-        g_log << endl;
-      }
-      else {
-        resolver.d_slog->info(Logr::Info, "Question");
-      }
+      resolver.d_slog->info(Logr::Info, "Question");
     }
 
     if (!comboWriter->d_mdp.d_header.rd) {
@@ -1878,34 +1868,21 @@ void startDoResolve(void* arg) // NOLINT(readability-function-cognitive-complexi
     // Now it always uses an integral number of microseconds, except for averages, which use doubles
     uint64_t spentUsec = uSec(resolver.getNow() - comboWriter->d_now);
     if (!g_quiet) {
-      if (!g_slogStructured) {
-        g_log << Logger::Error << RecThreadInfo::thread_local_id() << " [" << g_multiTasker->getTid() << "/" << g_multiTasker->numProcesses() << "] answer to " << (comboWriter->d_mdp.d_header.rd ? "" : "non-rd ") << "question '" << comboWriter->d_mdp.d_qname << "|" << DNSRecordContent::NumberToType(comboWriter->d_mdp.d_qtype);
-        g_log << "': " << ntohs(packetWriter.getHeader()->ancount) << " answers, " << ntohs(packetWriter.getHeader()->arcount) << " additional, took " << resolver.d_outqueries << " packets, " << resolver.d_totUsec / 1000.0 << " netw ms, " << static_cast<double>(spentUsec) / 1000.0 << " tot ms, " << resolver.d_throttledqueries << " throttled, " << resolver.d_timeouts << " timeouts, " << resolver.d_tcpoutqueries << "/" << resolver.d_dotoutqueries << " tcp/dot connections, rcode=" << res;
-
-        if (!shouldNotValidate && resolver.isDNSSECValidationRequested()) {
-          g_log << ", dnssec=" << resolver.getValidationState();
-        }
-        g_log << " answer-is-variable=" << resolver.wasVariable() << ", into-packetcache=" << intoPC;
-        g_log << " maxdepth=" << resolver.d_maxdepth;
-        g_log << endl;
-      }
-      else {
-        resolver.d_slog->info(Logr::Info, "Answer", "rd", Logging::Loggable(comboWriter->d_mdp.d_header.rd),
-                              "answers", Logging::Loggable(ntohs(packetWriter.getHeader()->ancount)),
-                              "additional", Logging::Loggable(ntohs(packetWriter.getHeader()->arcount)),
-                              "outqueries", Logging::Loggable(resolver.d_outqueries),
-                              "netms", Logging::Loggable(resolver.d_totUsec / 1000.0),
-                              "totms", Logging::Loggable(static_cast<double>(spentUsec) / 1000.0),
-                              "throttled", Logging::Loggable(resolver.d_throttledqueries),
-                              "timeouts", Logging::Loggable(resolver.d_timeouts),
-                              "tcpout", Logging::Loggable(resolver.d_tcpoutqueries),
-                              "dotout", Logging::Loggable(resolver.d_dotoutqueries),
-                              "rcode", Logging::Loggable(res),
-                              "validationState", Logging::Loggable(resolver.getValidationState()),
-                              "answer-is-variable", Logging::Loggable(resolver.wasVariable()),
-                              "into-packetcache", Logging::Loggable(intoPC),
-                              "maxdepth", Logging::Loggable(resolver.d_maxdepth));
-      }
+      resolver.d_slog->info(Logr::Info, "Answer", "rd", Logging::Loggable(comboWriter->d_mdp.d_header.rd),
+                            "answers", Logging::Loggable(ntohs(packetWriter.getHeader()->ancount)),
+                            "additional", Logging::Loggable(ntohs(packetWriter.getHeader()->arcount)),
+                            "outqueries", Logging::Loggable(resolver.d_outqueries),
+                            "netms", Logging::Loggable(resolver.d_totUsec / 1000.0),
+                            "totms", Logging::Loggable(static_cast<double>(spentUsec) / 1000.0),
+                            "throttled", Logging::Loggable(resolver.d_throttledqueries),
+                            "timeouts", Logging::Loggable(resolver.d_timeouts),
+                            "tcpout", Logging::Loggable(resolver.d_tcpoutqueries),
+                            "dotout", Logging::Loggable(resolver.d_dotoutqueries),
+                            "rcode", Logging::Loggable(res),
+                            "validationState", Logging::Loggable(resolver.getValidationState()),
+                            "answer-is-variable", Logging::Loggable(resolver.wasVariable()),
+                            "into-packetcache", Logging::Loggable(intoPC),
+                            "maxdepth", Logging::Loggable(resolver.d_maxdepth));
     }
 
     if (comboWriter->d_mdp.d_header.opcode == static_cast<unsigned>(Opcode::Query)) {
@@ -1957,9 +1934,7 @@ void startDoResolve(void* arg) // NOLINT(readability-function-cognitive-complexi
       resolver.d_slog->error(Logr::Error, ne.what(), "Nested exception in resolver context", Logging::Loggable("std::exception"));
     }
     catch (...) {
-    }
-    if (!g_slogStructured) {
-      g_log << endl;
+      ;
     }
   }
   catch (...) {
index 52669e277e34b98d2588af531cdf6f2e5c56e675..9af131491034aeb23e57eddfb8aee811fe8c9a54 100644 (file)
@@ -201,28 +201,10 @@ static void setCPUMap(const std::map<unsigned int, std::set<int>>& cpusMap, unsi
   }
   int ret = mapThreadToCPUList(tid, cpuMapping->second);
   if (ret == 0) {
-    if (!g_slogStructured) {
-      g_log << Logger::Info << "CPU affinity for thread " << n << " has been set to CPU map:";
-      for (const auto cpu : cpuMapping->second) {
-        g_log << Logger::Info << " " << cpu;
-      }
-      g_log << Logger::Info << endl;
-    }
-    else {
-      log->info(Logr::Info, "CPU affinity has been set", "thread", Logging::Loggable(n), "cpumap", Logging::IterLoggable(cpuMapping->second.begin(), cpuMapping->second.end()));
-    }
+    log->info(Logr::Info, "CPU affinity has been set", "thread", Logging::Loggable(n), "cpumap", Logging::IterLoggable(cpuMapping->second.begin(), cpuMapping->second.end()));
   }
   else {
-    if (!g_slogStructured) {
-      g_log << Logger::Warning << "Error setting CPU affinity for thread " << n << " to CPU map:";
-      for (const auto cpu : cpuMapping->second) {
-        g_log << Logger::Info << " " << cpu;
-      }
-      g_log << Logger::Info << ' ' << stringerror(ret) << endl;
-    }
-    else {
-      log->error(Logr::Warning, ret, "Error setting CPU affinity", "thread", Logging::Loggable(n), "cpumap", Logging::IterLoggable(cpuMapping->second.begin(), cpuMapping->second.end()));
-    }
+    log->error(Logr::Warning, ret, "Error setting CPU affinity", "thread", Logging::Loggable(n), "cpumap", Logging::IterLoggable(cpuMapping->second.begin(), cpuMapping->second.end()));
   }
 }
 
@@ -1330,19 +1312,7 @@ static std::shared_ptr<NetmaskGroup> parseACL(const std::string& aclFile, const
     for (const auto& address : ips) {
       result->addMask(address);
     }
-    if (!g_slogStructured) {
-      g_log << Logger::Info << aclSetting << ": ";
-      for (auto i = ips.begin(); i != ips.end(); ++i) {
-        if (i != ips.begin()) {
-          g_log << Logger::Info << ", ";
-        }
-        g_log << Logger::Info << *i;
-      }
-      g_log << Logger::Info << endl;
-    }
-    else {
-      log->info(Logr::Info, "Setting access control", "acl", Logging::Loggable(aclSetting), "addresses", Logging::IterLoggable(ips.begin(), ips.end()));
-    }
+    log->info(Logr::Info, "Setting access control", "acl", Logging::Loggable(aclSetting), "addresses", Logging::IterLoggable(ips.begin(), ips.end()));
   }
 
   return result;
@@ -1723,19 +1693,7 @@ static int initDNSSEC(Logr::log_t log)
     }
   }
   if (!nums.empty()) {
-    if (!g_slogStructured) {
-      g_log << Logger::Warning << (automatic ? "Automatically" : "Manually") << " disabled DNSSEC algorithms: ";
-      for (auto i = nums.begin(); i != nums.end(); ++i) {
-        if (i != nums.begin()) {
-          g_log << Logger::Warning << ", ";
-        }
-        g_log << Logger::Warning << *i;
-      }
-      g_log << Logger::Warning << endl;
-    }
-    else {
-      log->info(Logr::Notice, "Disabled DNSSEC algorithms", "automatically", Logging::Loggable(automatic), "algorithms", Logging::IterLoggable(nums.begin(), nums.end()));
-    }
+    log->info(Logr::Notice, "Disabled DNSSEC algorithms", "automatically", Logging::Loggable(automatic), "algorithms", Logging::IterLoggable(nums.begin(), nums.end()));
   }
 
   return 0;
@@ -1752,19 +1710,7 @@ static void initDontQuery(Logr::log_t log)
     for (const auto& anIP : ips) {
       SyncRes::addDontQuery(anIP);
     }
-    if (!g_slogStructured) {
-      g_log << Logger::Warning << "Will not send queries to: ";
-      for (auto i = ips.begin(); i != ips.end(); ++i) {
-        if (i != ips.begin()) {
-          g_log << Logger::Warning << ", ";
-        }
-        g_log << Logger::Warning << *i;
-      }
-      g_log << Logger::Warning << endl;
-    }
-    else {
-      log->info(Logr::Notice, "Will not send queries to", "addresses", Logging::IterLoggable(ips.begin(), ips.end()));
-    }
+    log->info(Logr::Notice, "Will not send queries to", "addresses", Logging::IterLoggable(ips.begin(), ips.end()));
   }
 }
 
index fea92f138d4ac30b42e9711767dda536011c3812..dba5c5dcdd694e966da21201b21838e4a70c2e09 100644 (file)
@@ -78,27 +78,7 @@ static void convertServersForAD(const std::string& zone, const std::string& inpu
     }
   }
   if (verbose) {
-    if (!g_slogStructured) {
-      g_log << Logger::Info << "Redirecting queries for zone '" << zone << "' ";
-      if (authDomain.d_rdForward) {
-        g_log << "with recursion ";
-      }
-      g_log << "to: ";
-      bool first = true;
-      for (const auto& address : addresses) {
-        if (!first) {
-          g_log << ", ";
-        }
-        else {
-          first = false;
-        }
-        g_log << address;
-      }
-      g_log << endl;
-    }
-    else {
-      log->info(Logr::Info, "Redirecting queries", "zone", Logging::Loggable(zone), "recursion", Logging::Loggable(authDomain.d_rdForward), "addresses", Logging::IterLoggable(addresses.begin(), addresses.end()));
-    }
+    log->info(Logr::Info, "Redirecting queries", "zone", Logging::Loggable(zone), "recursion", Logging::Loggable(authDomain.d_rdForward), "addresses", Logging::IterLoggable(addresses.begin(), addresses.end()));
   }
 }