]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
rec-main part of control channel structured logging
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Tue, 7 Jun 2022 06:24:48 +0000 (08:24 +0200)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Tue, 7 Jun 2022 07:12:51 +0000 (09:12 +0200)
pdns/dnsdistdist/Makefile.am
pdns/dnsdistdist/logging.hh [new symlink]
pdns/rec-lua-conf.cc
pdns/recursordist/rec-main.cc
pdns/recursordist/rec-tcp.cc
pdns/remote_logger.cc

index e6e04cc5965396cf8b11bcb968fe473d877512ab..e43ae2112d4b65febed644557946e83cbc71fc1f 100644 (file)
@@ -201,6 +201,7 @@ dnsdist_SOURCES = \
        iputils.cc iputils.hh \
        libssl.cc libssl.hh \
        lock.hh \
+       logging.hh \
        misc.cc misc.hh \
        mplexer.hh \
        namespaces.hh \
diff --git a/pdns/dnsdistdist/logging.hh b/pdns/dnsdistdist/logging.hh
new file mode 120000 (symlink)
index 0000000..020d82c
--- /dev/null
@@ -0,0 +1 @@
+../logging.hh
\ No newline at end of file
index 193add80234293f0f07ef55703018a34c6f54b7f..0b687bf1e31b7ca3e5bb471e0805308a1823a56a 100644 (file)
@@ -292,7 +292,7 @@ static void rpzPrimary(LuaConfigItems& lci, luaConfigDelayedThreads& delayedThre
     zone->setName(polName);
     zoneIdx = lci.dfe.addZone(zone);
 
-    auto log =  lci.d_slog->withValues("seedfile", Logging::Loggable(seedFile), "zone",  Logging::Loggable(zoneName));
+    auto log = lci.d_slog->withValues("seedfile", Logging::Loggable(seedFile), "zone", Logging::Loggable(zoneName));
     if (!seedFile.empty()) {
       SLOG(g_log << Logger::Info << "Pre-loading RPZ zone " << zoneName << " from seed file '" << seedFile << "'" << endl,
            log->info(Logr::Info, "Pre-loading RPZ zone from seed file"));
index 08682566ff4a90434c10601fe8be5a2dd6c0238a..520eebf6550113d7f15f1cff7f9f543afe374e94 100644 (file)
@@ -1926,13 +1926,15 @@ static void handlePipeRequest(int fd, FDMultiplexer::funcparam_t& var)
 
 static void handleRCC(int fd, FDMultiplexer::funcparam_t& var)
 {
+  auto log = g_slog->withName("control");
   try {
     FDWrapper clientfd = accept(fd, nullptr, nullptr);
     if (clientfd == -1) {
       throw PDNSException("accept failed");
     }
     string msg = g_rcc.recv(clientfd).d_str;
-    g_log << Logger::Info << "Received rec_control command '" << msg << "' via controlsocket" << endl;
+    SLOG(g_log << Logger::Info << "Received rec_control command '" << msg << "' via controlsocket" << endl,
+         log->info(Logr::Info, "Received rec_control command via controlsocket", "command", Logging::Loggable(msg)));
 
     RecursorControlParser rcp;
     RecursorControlParser::func_t* command;
@@ -1942,10 +1944,12 @@ static void handleRCC(int fd, FDMultiplexer::funcparam_t& var)
     command();
   }
   catch (const std::exception& e) {
-    g_log << Logger::Error << "Error dealing with control socket request: " << e.what() << endl;
+    SLOG(g_log << Logger::Error << "Error dealing with control socket request: " << e.what() << endl,
+         log->error(Logr::Error, e.what(), "Exception while dealing with control request", "exception", Logging::Loggable("std::exception")));
   }
   catch (const PDNSException& ae) {
-    g_log << Logger::Error << "Error dealing with control socket request: " << ae.reason << endl;
+    SLOG(g_log << Logger::Error << "Error dealing with control socket request: " << ae.reason << endl,
+         log->error(Logr::Error, ae.reason, "Exception while dealing with control request", "exception", Logging::Loggable("PDNSException")));
   }
 }
 
index 9aac57eca685eb51d888e71ae01f436c8e9ac2b5..d15fa64d13ed201ddd90c0ae548b9a3e9457051f 100644 (file)
@@ -864,7 +864,7 @@ void checkFastOpenSysctl(bool active, Logr::log_t log)
 #endif
 }
 
-void checkTFOconnect( Logr::log_t log)
+void checkTFOconnect(Logr::log_t log)
 {
   try {
     Socket s(AF_INET, SOCK_STREAM);
index 8ffb3b4285e8ae20d45bd0a0489cca89246989e1..96992c84fb45de1f8593fdc08f8c7cb095437e5b 100644 (file)
@@ -7,11 +7,11 @@
 #endif
 #ifdef PDNS_CONFIG_ARGS
 #include "logger.hh"
-#include "logging.hh"
 #define WE_ARE_RECURSOR
 #else
 #include "dolog.hh"
 #endif
+#include "logging.hh"
 
 bool CircularWriteBuffer::hasRoomFor(const std::string& str) const
 {
@@ -224,11 +224,11 @@ void RemoteLogger::maintenanceThread()
   }
   catch (const std::exception& e)
   {
-    SLOG(g_log << "Remote Logger's maintenance thead died on: " << e.what() << endl,
+    SLOG(cerr << "Remote Logger's maintenance thead died on: " << e.what() << endl,
          g_slog->withName("protobuf")->error(Logr::Error, e.what(), "Remote Logger's maintenance thead died"));
   }
   catch (...) {
-    SLOG(g_log << "Remote Logger's maintenance thead died on unknown exception" << endl,
+    SLOG(cerr << "Remote Logger's maintenance thead died on unknown exception" << endl,
           g_slog->withName("protobuf")->info(Logr::Error, "Remote Logger's maintenance thead died"));
   }
 }