]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Structured logging for root refresh
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Wed, 15 Jun 2022 06:57:52 +0000 (08:57 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Mon, 20 Jun 2022 12:41:44 +0000 (14:41 +0200)
pdns/syncres.cc

index 8fdc2bd26f3f3cbfba9e518d7c4722a3d8ce308b..07fdafe868cbe6cbf12494d912aa0eea3b6028a7 100644 (file)
@@ -5779,6 +5779,7 @@ int SyncRes::getRootNS(struct timeval now, asyncresolve_t asyncCallback, unsigne
   sr.setDNSSECValidationRequested(g_dnssecmode != DNSSECMode::Off && g_dnssecmode != DNSSECMode::ProcessNoValidate);
   sr.setAsyncCallback(asyncCallback);
 
+  const string msg = "Failed to update . records";
   vector<DNSRecord> ret;
   int res = -1;
   try {
@@ -5790,21 +5791,26 @@ int SyncRes::getRootNS(struct timeval now, asyncresolve_t asyncCallback, unsigne
       }
     }
   }
-  catch(const PDNSException& e) {
-    g_log<<Logger::Error<<"Failed to update . records, got an exception: "<<e.reason<<endl;
+  catch (const PDNSException& e) {
+    SLOG(g_log<<Logger::Error<<"Failed to update . records, got an exception: "<<e.reason<<endl,
+         log->error(Logr::Error, e.reason, msg, "exception", Logging::Loggable("PDNSException")));
   }
-  catch(const ImmediateServFailException& e) {
-    g_log<<Logger::Error<<"Failed to update . records, got an exception: "<<e.reason<<endl;
+  catch (const ImmediateServFailException& e) {
+    SLOG(g_log<<Logger::Error<<"Failed to update . records, got an exception: "<<e.reason<<endl,
+         log->error(Logr::Error, e.reason, msg, "exception", Logging::Loggable("ImmediateServFailException")));
   }
-  catch(const PolicyHitException& e) {
-    g_log<<Logger::Error<<"Failed to update . records, got a policy hit"<<endl;
+  catch (const PolicyHitException& e) {
+    SLOG(g_log<<Logger::Error<<"Failed to update . records, got a policy hit"<<endl,
+         log->info(Logr::Error, msg, "exception", Logging::Loggable("PolicyHitException")));
     ret.clear();
   }
-  catch(const std::exception& e) {
-    g_log<<Logger::Error<<"Failed to update . records, got an exception: "<<e.what()<<endl;
+  catch (const std::exception& e) {
+    SLOG(g_log<<Logger::Error<<"Failed to update . records, got an exception: "<<e.what()<<endl,
+         log->error(Logr::Error, e.what(), msg, "exception", Logging::Loggable("std::exception")));
   }
-  catch(...) {
-    g_log<<Logger::Error<<"Failed to update . records, got an exception"<<endl;
+  catch (...) {
+    SLOG(g_log<<Logger::Error<<"Failed to update . records, got an exception"<<endl,
+         log->info(Logr::Error, msg));
   }
 
   if (res == 0) {
@@ -5812,7 +5818,8 @@ int SyncRes::getRootNS(struct timeval now, asyncresolve_t asyncCallback, unsigne
          log->info(Logr::Debug, "Refreshed . records"));
   }
   else {
-    g_log<<Logger::Warning<<"Failed to update root NS records, RCODE="<<res<<endl;
+    SLOG(g_log<<Logger::Warning<<"Failed to update root NS records, RCODE="<<res<<endl,
+         log->info(Logr::Warning, msg, "rcode", Logging::Loggable(res)));
   }
   return res;
 }