]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
A few tweaks to structured logging calls 11959/head
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Wed, 22 Jun 2022 14:47:31 +0000 (16:47 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Thu, 15 Sep 2022 10:39:04 +0000 (12:39 +0200)
pdns/pdns_recursor.cc
pdns/recursordist/rec-main.cc
pdns/recursordist/rec-taskqueue.cc

index 4469695996db39ad1c129a98946352d2e8c6c38e..a9bfb82b90448df6b51fa90e0c034d141e34973c 100644 (file)
@@ -2450,7 +2450,7 @@ void makeUDPServerSockets(deferredAdd_t& deferredAdds, Logr::log_t log)
     }
     catch (const std::exception& e) {
       SLOG(g_log << Logger::Error << e.what() << endl,
-           log->error(Logr::Error, e.what(), "Exception while setting socker buffer size"));
+           log->error(Logr::Error, e.what(), "Exception while setting socket buffer size"));
     }
     sin.sin4.sin_port = htons(st.port);
 
index 818406e2a85685db699a9b4e02b19c47b40ee987..19c3581fef7fa27708347a1fa87ffdbe1ce932d6 100644 (file)
@@ -3012,17 +3012,17 @@ int main(int argc, char** argv)
   }
   catch (const PDNSException& ae) {
     SLOG(g_log << Logger::Error << "Exception: " << ae.reason << endl,
-         g_slog->withName("config")->error(Logr::Error, ae.reason, "Exception"));
+         g_slog->withName("config")->error(Logr::Critical, ae.reason, "Fatal error", "exception", Logging::Loggable("PDNSException")));
     ret = EXIT_FAILURE;
   }
   catch (const std::exception& e) {
     SLOG(g_log << Logger::Error << "STL Exception: " << e.what() << endl,
-         g_slog->withName("config")->error(Logr::Error, e.what(), "STL Exception"));
+         g_slog->withName("config")->error(Logr::Critical, e.what(), "Fatal error", "exception", Logging::Loggable("std::exception")));
     ret = EXIT_FAILURE;
   }
   catch (...) {
     SLOG(g_log << Logger::Error << "any other exception in main: " << endl,
-         g_slog->withName("config")->error(Logr::Error, "Unknown", "Exception"));
+         g_slog->withName("config")->info(Logr::Critical, "Fatal error"));
     ret = EXIT_FAILURE;
   }
 
@@ -3032,10 +3032,12 @@ int main(int argc, char** argv)
 static RecursorControlChannel::Answer* doReloadLuaScript()
 {
   string fname = ::arg()["lua-dns-script"];
+  auto log = g_slog->withName("runtime")->withValues("name", Logging::Loggable(fname));
   try {
     if (fname.empty()) {
       t_pdl.reset();
-      g_log << Logger::Info << RecThreadInfo::id() << " Unloaded current lua script" << endl;
+      SLOG(g_log << Logger::Info << RecThreadInfo::id() << " Unloaded current lua script" << endl,
+           log->info(Logr::Info, "Unloaded current lua script"));
       return new RecursorControlChannel::Answer{0, string("unloaded\n")};
     }
 
@@ -3045,16 +3047,19 @@ static RecursorControlChannel::Answer* doReloadLuaScript()
     }
     catch (std::runtime_error& ex) {
       string msg = std::to_string(RecThreadInfo::id()) + " Retaining current script, could not read '" + fname + "': " + ex.what();
-      g_log << Logger::Error << msg << endl;
+      SLOG(g_log << Logger::Error << msg << endl,
+           log->error(Logr::Error, ex.what(), "Retaining current script, could not read new script"));
       return new RecursorControlChannel::Answer{1, msg + "\n"};
     }
   }
   catch (std::exception& e) {
-    g_log << Logger::Error << RecThreadInfo::id() << " Retaining current script, error from '" << fname << "': " << e.what() << endl;
+    SLOG(g_log << Logger::Error << RecThreadInfo::id() << " Retaining current script, error from '" << fname << "': " << e.what() << endl,
+         log->error(Logr::Error, e.what(), "Retaining current script, error in new script"));
     return new RecursorControlChannel::Answer{1, string("retaining current script, error from '" + fname + "': " + e.what() + "\n")};
   }
 
-  g_log << Logger::Warning << RecThreadInfo::id() << " (Re)loaded lua script from '" << fname << "'" << endl;
+  SLOG(g_log << Logger::Warning << RecThreadInfo::id() << " (Re)loaded lua script from '" << fname << "'" << endl,
+       log->info(Logr::Warning, "(Re)loaded lua script"));
   return new RecursorControlChannel::Answer{0, string("(re)loaded '" + fname + "'\n")};
 }
 
@@ -3105,7 +3110,9 @@ struct WipeCacheResult wipeCaches(const DNSName& canon, bool subtree, uint16_t q
     }
   }
   catch (const std::exception& e) {
-    g_log << Logger::Warning << ", failed: " << e.what() << endl;
+    auto log = g_slog->withName("runtime");
+    SLOG(g_log << Logger::Warning << ", failed: " << e.what() << endl,
+         log->error(Logr::Warning, e.what(), "Wipecache failed"));
   }
 
   return res;
index c3aa7d2704b71048e6d3f51dd31616fd7eca952a..f805ced72e4c1fad41c0652396048db1e1733e9a 100644 (file)
@@ -173,10 +173,10 @@ static void tryDoT(const struct timeval& now, bool logErrors, const pdns::Resolv
   sr.setRefreshAlmostExpired(false);
   bool ex = true;
   try {
-    log->info(Logr::Warning, "trying DoT");
+    log->info(Logr::Debug, "trying DoT");
     bool ok = sr.tryDoT(task.d_qname, QType(task.d_qtype), task.d_nsname, task.d_ip, now.tv_sec);
     ex = false;
-    log->info(Logr::Warning, "done", "ok", Logging::Loggable(ok));
+    log->info(Logr::Debug, "done", "ok", Logging::Loggable(ok));
   }
   catch (const std::exception& e) {
     log->error(Logr::Error, msg, e.what());