]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Move to structured logging for taskq. As this is almost 100%
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Wed, 16 Feb 2022 07:39:33 +0000 (08:39 +0100)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Thu, 17 Feb 2022 14:47:50 +0000 (15:47 +0100)
debug only logging, no backward compat mode

pdns/recursordist/rec-taskqueue.cc
pdns/recursordist/taskqueue.cc
pdns/recursordist/taskqueue.hh

index b9b8a61b68f9d6dcfb40746b0c837f95de4621da..4e2f5f1f233111eb71cf48e204b469f6b036898c 100644 (file)
@@ -22,7 +22,7 @@
 #include "rec-taskqueue.hh"
 #include "taskqueue.hh"
 #include "lock.hh"
-#include "logger.hh"
+#include "logging.hh"
 #include "stat_t.hh"
 #include "syncres.hh"
 
@@ -45,35 +45,36 @@ static struct taskstats s_resolve_tasks;
 
 static void resolve(const struct timeval& now, bool logErrors, const pdns::ResolveTask& task) noexcept
 {
+  auto log = g_slog->withName("taskq")->withValues("name", Logging::Loggable(task.d_qname), "qtype", Logging::Loggable(QType(task.d_qtype).toString()));
   const string msg = "Exception while running a background ResolveTask";
   SyncRes sr(now);
   vector<DNSRecord> ret;
   sr.setRefreshAlmostExpired(task.d_refreshMode);
   bool ex = true;
   try {
-    g_log << Logger::Debug << "TaskQueue: resolving " << task.d_qname.toString() << '|' << QType(task.d_qtype).toString() << endl;
+    log->info(Logr::Debug, "resolving");
     int res = sr.beginResolve(task.d_qname, QType(task.d_qtype), QClass::IN, ret);
     ex = false;
-    g_log << Logger::Debug << "TaskQueue: DONE resolving " << task.d_qname.toString() << '|' << QType(task.d_qtype).toString() << ": " << res << endl;
+    log->info(Logr::Debug, "done", "rcode", Logging::Loggable(res), "records",  Logging::Loggable(ret.size()));
   }
   catch (const std::exception& e) {
-    g_log << Logger::Error << msg << ": " << e.what() << endl;
+    log->error(Logr::Error, msg, e.what());
   }
   catch (const PDNSException& e) {
-    g_log << Logger::Notice << msg << ": " << e.reason << endl;
+    log->error(Logr::Error, msg, e.reason);
   }
   catch (const ImmediateServFailException& e) {
     if (logErrors) {
-      g_log << Logger::Notice << msg << ": " << e.reason << endl;
+      log->error(Logr::Error, msg, e.reason);
     }
   }
   catch (const PolicyHitException& e) {
     if (logErrors) {
-      g_log << Logger::Notice << msg << ": PolicyHit" << endl;
+      log->error(Logr::Notice, msg, "PolicyHit");
     }
   }
   catch (...) {
-    g_log << Logger::Error << msg << endl;
+    log->error(Logr::Error, msg, "Unexpectec exception");
   }
   if (ex) {
     if (task.d_refreshMode) {
index cc1a4b4be7c8286f1f8e49ced1105f4c1f575e4b..7e810015b22952f79301d9cccea6bca511a2b48c 100644 (file)
@@ -22,7 +22,7 @@
 
 #include "taskqueue.hh"
 
-#include "logger.hh"
+#include "logging.hh"
 #include "syncres.hh"
 
 namespace pdns
@@ -47,7 +47,8 @@ ResolveTask TaskQueue::pop()
 bool ResolveTask::run(bool logErrors)
 {
   if (!d_func) {
-    g_log << Logger::Debug << "TaskQueue: null task for " << d_qname.toString() << '|' << QType(d_qtype).toString() << endl;
+    auto log = g_slog->withName("taskq")->withValues("name", Logging::Loggable(d_qname), "qtype", Logging::Loggable(QType(d_qtype).toString()));
+    log->error(Logr::Debug, "null task");
     return false;
   }
   struct timeval now;
@@ -57,7 +58,8 @@ bool ResolveTask::run(bool logErrors)
   }
   else {
     // Deadline passed
-    g_log << Logger::Debug << "TaskQueue: deadline for " << d_qname.toString() << '|' << QType(d_qtype).toString() << " passed" << endl;
+    auto log = g_slog->withName("taskq")->withValues("name", Logging::Loggable(d_qname), "qtype", Logging::Loggable(QType(d_qtype).toString()));
+    log->error(Logr::Debug, "deadline passed");
     return true;
   }
   return false;
index 624d87d1d5e9353d2213daa455e153fb9e977bc8..a457823138254d1c521bbeaba59656b5bd0b4d24 100644 (file)
@@ -49,7 +49,7 @@ struct ResolveTask
 
   bool operator<(const ResolveTask& a) const
   {
-    return tie(d_qname, d_qtype, d_refreshMode) < tie(d_qname, d_qtype, d_refreshMode);
+    return std::tie(d_qname, d_qtype, d_refreshMode) < std::tie(d_qname, d_qtype, d_refreshMode);
   }
   bool run(bool logErrors);
 };