From: Otto Moerbeek Date: Tue, 7 Jun 2022 06:24:48 +0000 (+0200) Subject: rec-main part of control channel structured logging X-Git-Tag: auth-4.8.0-alpha0~69^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=43f91cad4204d5b5352bc437795cacfc8300de9e;p=thirdparty%2Fpdns.git rec-main part of control channel structured logging --- diff --git a/pdns/dnsdistdist/Makefile.am b/pdns/dnsdistdist/Makefile.am index e6e04cc596..e43ae2112d 100644 --- a/pdns/dnsdistdist/Makefile.am +++ b/pdns/dnsdistdist/Makefile.am @@ -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 index 0000000000..020d82c1ef --- /dev/null +++ b/pdns/dnsdistdist/logging.hh @@ -0,0 +1 @@ +../logging.hh \ No newline at end of file diff --git a/pdns/rec-lua-conf.cc b/pdns/rec-lua-conf.cc index 193add8023..0b687bf1e3 100644 --- a/pdns/rec-lua-conf.cc +++ b/pdns/rec-lua-conf.cc @@ -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")); diff --git a/pdns/recursordist/rec-main.cc b/pdns/recursordist/rec-main.cc index 08682566ff..520eebf655 100644 --- a/pdns/recursordist/rec-main.cc +++ b/pdns/recursordist/rec-main.cc @@ -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"))); } } diff --git a/pdns/recursordist/rec-tcp.cc b/pdns/recursordist/rec-tcp.cc index 9aac57eca6..d15fa64d13 100644 --- a/pdns/recursordist/rec-tcp.cc +++ b/pdns/recursordist/rec-tcp.cc @@ -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); diff --git a/pdns/remote_logger.cc b/pdns/remote_logger.cc index 8ffb3b4285..96992c84fb 100644 --- a/pdns/remote_logger.cc +++ b/pdns/remote_logger.cc @@ -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")); } }