From: Otto Moerbeek Date: Wed, 9 Jul 2025 11:52:31 +0000 (+0200) Subject: rec: remove old style logging calls from rec specific code X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7023bcb5bb7823930d4346505c5c57693f00e6c3;p=thirdparty%2Fpdns.git rec: remove old style logging calls from rec specific code Signed-off-by: Otto Moerbeek --- diff --git a/pdns/recursordist/lua-recursor4.cc b/pdns/recursordist/lua-recursor4.cc index 9552dc2f7..ada61fbcd 100644 --- a/pdns/recursordist/lua-recursor4.cc +++ b/pdns/recursordist/lua-recursor4.cc @@ -371,8 +371,7 @@ void RecursorLua4::postPrepareContext() // NOLINT(readability-function-cognitive } } catch(std::exception& e) { - SLOG(g_log <withName("lua")->error(Logr::Error, e.what(), "Error in call to DNSSuffixMatchGroup:add")); + g_slog->withName("lua")->error(Logr::Error, e.what(), "Error in call to DNSSuffixMatchGroup:add"); } } ); @@ -587,8 +586,7 @@ void RecursorLua4::runStartStopFunction(const string& script, bool start, Logr:: static void warnDrop(const RecursorLua4::DNSQuestion& dnsQuestion) { if (dnsQuestion.rcode == -2) { - SLOG(g_log << Logger::Error << "Returning -2 (pdns.DROP) is not supported anymore, see https://docs.powerdns.com/recursor/lua-scripting/hooks.html#hooksemantics" << endl, - g_slog->withName("lua")->info(Logr::Error, "Returning -2 (pdns.DROP) is not supported anymore, see https://docs.powerdns.com/recursor/lua-scripting/hooks.html#hooksemantics")); + g_slog->withName("lua")->info(Logr::Error, "Returning -2 (pdns.DROP) is not supported anymore, see https://docs.powerdns.com/recursor/lua-scripting/hooks.html#hooksemantics"); // We *could* set policy here, but that would also mean interfering with rcode and the return code of the hook. // So leave it at the error message. } @@ -837,8 +835,7 @@ bool RecursorLua4::genhook(const luacall_t& func, DNSQuestion& dnsQuestion, int& // coverity[auto_causes_copy] not copying produces a dangling ref const auto cbFunc = d_lw->readVariable>(dnsQuestion.udpCallback).get_value_or(nullptr); if (!cbFunc) { - SLOG(g_log << Logger::Error << "Attempted callback for Lua UDP Query/Response which could not be found" << endl, - g_slog->withName("lua")->info(Logr::Error, "Attempted callback for Lua UDP Query/Response which could not be found")); + g_slog->withName("lua")->info(Logr::Error, "Attempted callback for Lua UDP Query/Response which could not be found"); return false; } bool result = cbFunc(&dnsQuestion); diff --git a/pdns/recursordist/lwres.cc b/pdns/recursordist/lwres.cc index c0c9d6787..7f7d74115 100644 --- a/pdns/recursordist/lwres.cc +++ b/pdns/recursordist/lwres.cc @@ -69,20 +69,17 @@ void remoteLoggerQueueData(RemoteLoggerInterface& rli, const std::string& data) break; case RemoteLoggerInterface::Result::PipeFull: { const auto& msg = RemoteLoggerInterface::toErrorString(ret); - SLOG(g_log << Logger::Debug << rli.name() << ": " << msg << std::endl, - g_slog->withName(rli.name())->info(Logr::Debug, msg)); + g_slog->withName(rli.name())->info(Logr::Debug, msg); break; } case RemoteLoggerInterface::Result::TooLarge: { const auto& msg = RemoteLoggerInterface::toErrorString(ret); - SLOG(g_log << Logger::Notice << rli.name() << ": " << msg << endl, - g_slog->withName(rli.name())->info(Logr::Debug, msg)); + g_slog->withName(rli.name())->info(Logr::Debug, msg); break; } case RemoteLoggerInterface::Result::OtherError: { const auto& msg = RemoteLoggerInterface::toErrorString(ret); - SLOG(g_log << Logger::Warning << rli.name() << ": " << msg << std::endl, - g_slog->withName(rli.name())->info(Logr::Warning, msg)); + g_slog->withName(rli.name())->info(Logr::Warning, msg); break; } } @@ -313,8 +310,7 @@ static bool tcpconnect(const ComboAddress& ip, TCPOutConnectionManager::Connecti // tlsParams.d_caStore tlsCtx = getTLSContext(tlsParams); if (tlsCtx == nullptr) { - SLOG(g_log << Logger::Error << "DoT to " << ip << " requested but not available" << endl, - g_slogout->info(Logr::Error, "DoT requested but not available", "server", Logging::Loggable(ip))); + g_slogout->info(Logr::Error, "DoT requested but not available", "server", Logging::Loggable(ip)); dnsOverTLS = false; } } @@ -578,11 +574,10 @@ static LWResult::Result asyncresolve(const ComboAddress& address, const DNSName& if (domain != mdp.d_qname) { if (!mdp.d_qname.empty() && domain.toString().find((char)0) == string::npos /* ugly */) { // embedded nulls are too noisy, plus empty domains are too - SLOG(g_log << Logger::Notice << "Packet purporting to come from remote server " << address.toString() << " contained wrong answer: '" << domain << "' != '" << mdp.d_qname << "'" << endl, - g_slogout->info(Logr::Notice, "Packet purporting to come from remote server contained wrong answer", - "server", Logging::Loggable(address), - "qname", Logging::Loggable(domain), - "onwire", Logging::Loggable(mdp.d_qname))); + g_slogout->info(Logr::Notice, "Packet purporting to come from remote server contained wrong answer", + "server", Logging::Loggable(address), + "qname", Logging::Loggable(domain), + "onwire", Logging::Loggable(mdp.d_qname)); } // unexpected count has already been done @ pdns_recursor.cc goto out; @@ -639,9 +634,8 @@ static LWResult::Result asyncresolve(const ComboAddress& address, const DNSName& } catch (const std::exception& mde) { if (::arg().mustDo("log-common-errors")) { - SLOG(g_log << Logger::Notice << "Unable to parse packet from remote server " << address.toString() << ": " << mde.what() << endl, - g_slogout->error(Logr::Notice, mde.what(), "Unable to parse packet from remote server", "server", Logging::Loggable(address), - "exception", Logging::Loggable("std::exception"))); + g_slogout->error(Logr::Notice, mde.what(), "Unable to parse packet from remote server", "server", Logging::Loggable(address), + "exception", Logging::Loggable("std::exception")); } lwr->d_rcode = RCode::FormErr; @@ -655,8 +649,7 @@ static LWResult::Result asyncresolve(const ComboAddress& address, const DNSName& return LWResult::Result::Success; // success - oddly enough } catch (...) { - SLOG(g_log << Logger::Notice << "Unknown error parsing packet from remote server" << endl, - g_slogout->info(Logr::Notice, "Unknown error parsing packet from remote server", "server", Logging::Loggable(address))); + g_slogout->info(Logr::Notice, "Unknown error parsing packet from remote server", "server", Logging::Loggable(address)); } t_Counters.at(rec::Counter::serverParseError)++; diff --git a/pdns/recursordist/nod.cc b/pdns/recursordist/nod.cc index b1c12fc44..6d4be577c 100644 --- a/pdns/recursordist/nod.cc +++ b/pdns/recursordist/nod.cc @@ -81,8 +81,7 @@ bool PersistentSBF::init(bool ignore_pid) std::ifstream infile; try { infile.open(filename, std::ios::in | std::ios::binary); - SLOG(g_log << Logger::Warning << "Found SBF file " << filename << endl, - log->info(Logr::Warning, "Found SBF File", "file", Logging::Loggable(filename))); + log->info(Logr::Warning, "Found SBF File", "file", Logging::Loggable(filename)); // read the file into the sbf d_sbf.lock()->restore(infile); infile.close(); @@ -94,15 +93,13 @@ bool PersistentSBF::init(bool ignore_pid) catch (const std::runtime_error& e) { infile.close(); filesystem::remove(newest_file); - SLOG(g_log << Logger::Warning << "NODDB init: Cannot parse file: " << filename << ": " << e.what() << "; removed" << endl, - log->error(Logr::Warning, e.what(), "NODDB init: Cannot parse file, removed", "file", Logging::Loggable(filename))); + log->error(Logr::Warning, e.what(), "NODDB init: Cannot parse file, removed", "file", Logging::Loggable(filename)); } } } } catch (const filesystem::filesystem_error& e) { - SLOG(g_log << Logger::Warning << "NODDB init failed: " << e.what() << endl, - log->error(Logr::Warning, e.what(), "NODDB init failed", "exception", Logging::Loggable("filesystem::filesystem_error"))); + log->error(Logr::Warning, e.what(), "NODDB init failed", "exception", Logging::Loggable("filesystem::filesystem_error")); return false; } } @@ -161,21 +158,18 @@ bool PersistentSBF::snapshotCurrent(std::thread::id tid) filesystem::rename(ftmp, file); } catch (const std::runtime_error& e) { - SLOG(g_log << Logger::Warning << "NODDB snapshot: Cannot rename file: " << e.what() << endl, - log->error(Logr::Warning, e.what(), "NODDB snapshot: Cannot rename file", "exception", Logging::Loggable("std::runtime_error"))); + log->error(Logr::Warning, e.what(), "NODDB snapshot: Cannot rename file", "exception", Logging::Loggable("std::runtime_error")); filesystem::remove(ftmp); throw; } return true; } catch (const std::runtime_error& e) { - SLOG(g_log << Logger::Warning << "NODDB snapshot: Cannot write file: " << e.what() << endl, - log->error(Logr::Warning, e.what(), "NODDB snapshot: Cannot write file", "exception", Logging::Loggable("std::runtime_error"))); + log->error(Logr::Warning, e.what(), "NODDB snapshot: Cannot write file", "exception", Logging::Loggable("std::runtime_error")); } } else { - SLOG(g_log << Logger::Warning << "NODDB snapshot: Cannot write file: " << file.string() << endl, - log->info(Logr::Warning, "NODDB snapshot: Cannot write file", "file", Logging::Loggable(file.string()))); + log->info(Logr::Warning, "NODDB snapshot: Cannot write file", "file", Logging::Loggable(file.string())); } } return false; diff --git a/pdns/recursordist/pdns_recursor.cc b/pdns/recursordist/pdns_recursor.cc index bb34ebfef..a50886656 100644 --- a/pdns/recursordist/pdns_recursor.cc +++ b/pdns/recursordist/pdns_recursor.cc @@ -112,8 +112,7 @@ LWResult::Result UDPClientSocks::getSocket(const ComboAddress& toaddr, int* file closesocket(*fileDesc); } catch (const PDNSException& e) { - SLOG(g_log << Logger::Error << "Error closing UDP socket after connect() failed: " << e.reason << endl, - g_slogout->error(Logr::Error, e.reason, "Error closing UDP socket after connect() failed", "exception", Logging::Loggable("PDNSException"))); + g_slogout->error(Logr::Error, e.reason, "Error closing UDP socket after connect() failed", "exception", Logging::Loggable("PDNSException")); } if (err == ENETUNREACH) { // Seth "My Interfaces Are Like A Yo Yo" Arnold special @@ -141,8 +140,7 @@ void UDPClientSocks::returnSocket(int fileDesc) closesocket(fileDesc); } catch (const PDNSException& e) { - SLOG(g_log << Logger::Error << "Error closing returned UDP socket: " << e.reason << endl, - g_slogout->error(Logr::Error, e.reason, "Error closing returned UDP socket", "exception", Logging::Loggable("PDNSException"))); + g_slogout->error(Logr::Error, e.reason, "Error closing returned UDP socket", "exception", Logging::Loggable("PDNSException")); } --d_numsocks; @@ -215,8 +213,7 @@ static void handleGenUDPQueryResponse(int fileDesc, FDMultiplexer::funcparam_t& ssize_t ret = recvfrom(fileDesc, resp.data(), resp.size(), 0, reinterpret_cast(&fromaddr), &addrlen); // NOLINT(cppcoreguidelines-pro-type-reinterpret-cast) if (fromaddr != pident->remote) { - SLOG(g_log << Logger::Notice << "Response received from the wrong remote host (" << fromaddr.toStringWithPort() << " instead of " << pident->remote.toStringWithPort() << "), discarding" << endl, - g_slog->withName("lua")->info(Logr::Notice, "Response received from the wrong remote host. discarding", "method", Logging::Loggable("GenUDPQueryResponse"), "fromaddr", Logging::Loggable(fromaddr), "expected", Logging::Loggable(pident->remote))); + g_slog->withName("lua")->info(Logr::Notice, "Response received from the wrong remote host. discarding", "method", Logging::Loggable("GenUDPQueryResponse"), "fromaddr", Logging::Loggable(fromaddr), "expected", Logging::Loggable(pident->remote)); } t_fdm->removeReadFD(fileDesc); @@ -383,12 +380,11 @@ LWResult::Result arecvfrom(PacketBuffer& packet, int /* flags */, const ComboAdd if (nearMissLimit > 0 && pident->nearMisses > nearMissLimit) { /* we have received more than nearMissLimit answers on the right IP and port, from the right source (we are using connected sockets), for the correct qname and qtype, but with an unexpected message ID. That looks like a spoofing attempt. */ - SLOG(g_log << Logger::Error << "Too many (" << pident->nearMisses << " > " << nearMissLimit << ") answers with a wrong message ID for '" << domain << "' from " << fromAddr.toString() << ", assuming spoof attempt." << endl, - g_slogudpin->info(Logr::Error, "Too many answers with a wrong message ID, assuming spoofing attempt", - "nearmisses", Logging::Loggable(pident->nearMisses), - "nearmisslimit", Logging::Loggable(nearMissLimit), - "qname", Logging::Loggable(domain), - "from", Logging::Loggable(fromAddr))); + g_slogudpin->info(Logr::Error, "Too many answers with a wrong message ID, assuming spoofing attempt", + "nearmisses", Logging::Loggable(pident->nearMisses), + "nearmisslimit", Logging::Loggable(nearMissLimit), + "qname", Logging::Loggable(domain), + "from", Logging::Loggable(fromAddr)); t_Counters.at(rec::Counter::spoofCount)++; return LWResult::Result::Spoofed; } @@ -541,8 +537,7 @@ static PolicyResult handlePolicyHit(const DNSFilterEngine::Policy& appliedPolicy } if (resolver.doLog() && appliedPolicy.d_type != DNSFilterEngine::PolicyType::None) { - SLOG(g_log << Logger::Warning << comboWriter->d_mdp.d_qname << "|" << QType(comboWriter->d_mdp.d_qtype) << appliedPolicy.getLogString() << endl, - appliedPolicy.info(Logr::Warning, resolver.d_slog)); + appliedPolicy.info(Logr::Warning, resolver.d_slog); } if (appliedPolicy.d_zoneData && appliedPolicy.d_zoneData->d_extendedErrorCode) { @@ -593,27 +588,24 @@ static PolicyResult handlePolicyHit(const DNSFilterEngine::Policy& appliedPolicy } catch (const ImmediateServFailException& e) { if (g_logCommonErrors) { - SLOG(g_log << Logger::Notice << "Sending SERVFAIL to " << comboWriter->getRemote() << " during resolve of the custom filter policy '" << appliedPolicy.getName() << "' while resolving '" << comboWriter->d_mdp.d_qname << "' because: " << e.reason << endl, - resolver.d_slog->error(Logr::Notice, e.reason, "Sending SERVFAIL during resolve of the custom filter policy", - "policyName", Logging::Loggable(appliedPolicy.getName()), "exception", Logging::Loggable("ImmediateServFailException"))); + resolver.d_slog->error(Logr::Notice, e.reason, "Sending SERVFAIL during resolve of the custom filter policy", + "policyName", Logging::Loggable(appliedPolicy.getName()), "exception", Logging::Loggable("ImmediateServFailException")); } res = RCode::ServFail; break; } catch (const pdns::validation::TooManySEC3IterationsException& e) { if (g_logCommonErrors || (g_dnssecLogBogus && resolver.getDNSSECLimitHit())) { - SLOG(g_log << Logger::Notice << "Sending SERVFAIL to " << comboWriter->getRemote() << " during resolve of the custom filter policy '" << appliedPolicy.getName() << "' while resolving '" << comboWriter->d_mdp.d_qname << "' because: " << e.what() << endl, - resolver.d_slog->error(Logr::Notice, e.what(), "Sending SERVFAIL during resolve of the custom filter policy", - "policyName", Logging::Loggable(appliedPolicy.getName()), "exception", Logging::Loggable("TooManySEC3IterationsException"), "dnsseclimithit", Logging::Loggable(resolver.getDNSSECLimitHit()))); + resolver.d_slog->error(Logr::Notice, e.what(), "Sending SERVFAIL during resolve of the custom filter policy", + "policyName", Logging::Loggable(appliedPolicy.getName()), "exception", Logging::Loggable("TooManySEC3IterationsException"), "dnsseclimithit", Logging::Loggable(resolver.getDNSSECLimitHit())); } res = RCode::ServFail; break; } catch (const PolicyHitException& e) { if (g_logCommonErrors) { - SLOG(g_log << Logger::Notice << "Sending SERVFAIL to " << comboWriter->getRemote() << " during resolve of the custom filter policy '" << appliedPolicy.getName() << "' while resolving '" << comboWriter->d_mdp.d_qname << "' because another RPZ policy was hit" << endl, - resolver.d_slog->info(Logr::Notice, "Sending SERVFAIL during resolve of the custom filter policy because another RPZ policy was hit", - "policyName", Logging::Loggable(appliedPolicy.getName()), "exception", Logging::Loggable("PolicyHitException"))); + resolver.d_slog->info(Logr::Notice, "Sending SERVFAIL during resolve of the custom filter policy because another RPZ policy was hit", + "policyName", Logging::Loggable(appliedPolicy.getName()), "exception", Logging::Loggable("PolicyHitException")); } res = RCode::ServFail; break; @@ -640,8 +632,7 @@ static bool nodCheckNewDomain(Logr::log_t nodlogger, const DNSName& dname) if (g_nodDBp && g_nodDBp->isNewDomain(dname)) { if (g_nodLog) { // This should probably log to a dedicated log file - SLOG(g_log << Logger::Notice << "Newly observed domain nod=" << dname << endl, - nodlogger->info(Logr::Notice, "New domain observed")); + nodlogger->info(Logr::Notice, "New domain observed"); } t_Counters.at(rec::Counter::nodCount)++; ret = true; @@ -684,12 +675,11 @@ static bool udrCheckUniqueDNSRecord(Logr::log_t nodlogger, const DNSName& dname, if (g_udrDBp && g_udrDBp->isUniqueResponse(strStream.str())) { if (g_udrLog) { // This should also probably log to a dedicated file. - SLOG(g_log << Logger::Notice << "Unique response observed: qname=" << dname << " qtype=" << QType(qtype) << " rrtype=" << QType(record.d_type) << " rrname=" << record.d_name << " rrcontent=" << record.getContent()->getZoneRepresentation() << endl, - nodlogger->info(Logr::Notice, "New response observed", - "qtype", Logging::Loggable(QType(qtype)), - "rrtype", Logging::Loggable(QType(record.d_type)), - "rrname", Logging::Loggable(record.d_name), - "rrcontent", Logging::Loggable(record.getContent()->getZoneRepresentation()));); + nodlogger->info(Logr::Notice, "New response observed", + "qtype", Logging::Loggable(QType(qtype)), + "rrtype", Logging::Loggable(QType(record.d_type)), + "rrname", Logging::Loggable(record.d_name), + "rrcontent", Logging::Loggable(record.getContent()->getZoneRepresentation())); } t_Counters.at(rec::Counter::udrCount)++; ret = true; @@ -910,16 +900,14 @@ static void dumpTrace(const string& trace, const timeval& timev) int traceFd = dup(t_tracefd); if (traceFd == -1) { int err = errno; - SLOG(g_log << Logger::Error << "Could not dup trace file: " << stringerror(err) << endl, - g_slog->withName("trace")->error(Logr::Error, err, "Could not dup trace file")); + g_slog->withName("trace")->error(Logr::Error, err, "Could not dup trace file"); return; } setNonBlocking(traceFd); auto filep = pdns::UniqueFilePtr(fdopen(traceFd, "a")); if (!filep) { int err = errno; - SLOG(g_log << Logger::Error << "Could not write to trace file: " << stringerror(err) << endl, - g_slog->withName("trace")->error(Logr::Error, err, "Could not write to trace file")); + g_slog->withName("trace")->error(Logr::Error, err, "Could not write to trace file"); close(traceFd); return; } @@ -930,8 +918,7 @@ static void dumpTrace(const string& trace, const timeval& timev) isoDateTimeMillis(now, timebuf); if (ferror(filep.get()) != 0) { int err = errno; - SLOG(g_log << Logger::Error << "Problems writing to trace file: " << stringerror(err) << endl, - g_slog->withName("trace")->error(Logr::Error, err, "Problems writing to trace file")); + g_slog->withName("trace")->error(Logr::Error, err, "Problems writing to trace file"); // There's no guarantee the message below will end up in the stream, but we try our best clearerr(filep.get()); fprintf(filep.get(), "=== TRACE %s TRUNCATED; USE FILE ARGUMENT INSTEAD OF `-' ===\n", timebuf.data()); @@ -1317,21 +1304,18 @@ void startDoResolve(void* arg) // NOLINT(readability-function-cognitive-complexi catch (const ImmediateQueryDropException& e) { // XXX We need to export a protobuf message (and do a NOD lookup) if requested! t_Counters.at(rec::Counter::policyDrops)++; - SLOG(g_log << Logger::Debug << "Dropping query because of a filtering policy " << makeLoginfo(comboWriter) << endl, - resolver.d_slog->info(Logr::Debug, "Dropping query because of a filtering policy")); + resolver.d_slog->info(Logr::Debug, "Dropping query because of a filtering policy"); return; } catch (const ImmediateServFailException& e) { if (g_logCommonErrors) { - SLOG(g_log << Logger::Notice << "Sending SERVFAIL to " << comboWriter->getRemote() << " during resolve of '" << comboWriter->d_mdp.d_qname << "' because: " << e.reason << endl, - resolver.d_slog->error(Logr::Notice, e.reason, "Sending SERVFAIL during resolve")); + resolver.d_slog->error(Logr::Notice, e.reason, "Sending SERVFAIL during resolve"); } res = RCode::ServFail; } catch (const pdns::validation::TooManySEC3IterationsException& e) { if (g_logCommonErrors) { - SLOG(g_log << Logger::Notice << "Sending SERVFAIL to " << comboWriter->getRemote() << " during resolve of '" << comboWriter->d_mdp.d_qname << "' because: " << e.what() << endl, - resolver.d_slog->error(Logr::Notice, e.what(), "Sending SERVFAIL during resolve", "dnsseclimithit", Logging::Loggable(true))); + resolver.d_slog->error(Logr::Notice, e.what(), "Sending SERVFAIL during resolve", "dnsseclimithit", Logging::Loggable(true)); } res = RCode::ServFail; } @@ -1463,8 +1447,7 @@ void startDoResolve(void* arg) // NOLINT(readability-function-cognitive-complexi } if (state == vState::Secure) { if (resolver.doLog()) { - SLOG(g_log << Logger::Warning << "Answer to " << comboWriter->d_mdp.d_qname << "|" << QType(comboWriter->d_mdp.d_qtype) << x_marker << " for " << comboWriter->getRemote() << " validates correctly" << endl, - log->info(Logr::Info, "Validates Correctly")); + log->info(Logr::Info, "Validates Correctly"); } // Is the query source interested in the value of the ad-bit? @@ -1474,8 +1457,7 @@ void startDoResolve(void* arg) // NOLINT(readability-function-cognitive-complexi } else if (state == vState::Insecure) { if (resolver.doLog()) { - SLOG(g_log << Logger::Warning << "Answer to " << comboWriter->d_mdp.d_qname << "|" << QType(comboWriter->d_mdp.d_qtype) << x_marker << " for " << comboWriter->getRemote() << " validates as Insecure" << endl, - log->info(Logr::Info, "Validates as Insecure")); + log->info(Logr::Info, "Validates as Insecure"); } packetWriter.getHeader()->ad = 0; @@ -1488,15 +1470,13 @@ void startDoResolve(void* arg) // NOLINT(readability-function-cognitive-complexi t_bogusqueryring->push_back({comboWriter->d_mdp.d_qname, comboWriter->d_mdp.d_qtype}); } if (g_dnssecLogBogus || resolver.doLog() || g_dnssecmode == DNSSECMode::ValidateForLog) { - SLOG(g_log << Logger::Warning << "Answer to " << comboWriter->d_mdp.d_qname << "|" << QType(comboWriter->d_mdp.d_qtype) << x_marker << " for " << comboWriter->getRemote() << " validates as " << vStateToString(state) << endl, - log->info(Logr::Notice, "Validates as Bogus")); + log->info(Logr::Notice, "Validates as Bogus"); } // Does the query or validation mode sending out a SERVFAIL on validation errors? if (!packetWriter.getHeader()->cd && (g_dnssecmode == DNSSECMode::ValidateAll || comboWriter->d_mdp.d_header.ad || DNSSECOK)) { if (resolver.doLog()) { - SLOG(g_log << Logger::Warning << "Sending out SERVFAIL for " << comboWriter->d_mdp.d_qname << "|" << QType(comboWriter->d_mdp.d_qtype) << " because recursor or query demands it for Bogus results" << endl, - log->info(Logr::Notice, "Sending out SERVFAIL because recursor or query demands it for Bogus results")); + log->info(Logr::Notice, "Sending out SERVFAIL because recursor or query demands it for Bogus results"); } packetWriter.getHeader()->rcode = RCode::ServFail; @@ -1504,23 +1484,20 @@ void startDoResolve(void* arg) // NOLINT(readability-function-cognitive-complexi } else { if (resolver.doLog()) { - SLOG(g_log << Logger::Warning << "Not sending out SERVFAIL for " << comboWriter->d_mdp.d_qname << "|" << QType(comboWriter->d_mdp.d_qtype) << x_marker << " Bogus validation since neither config nor query demands this" << endl, - log->info(Logr::Notice, "Sending out SERVFAIL because recursor or query demands it for Bogus results")); + log->info(Logr::Notice, "Sending out SERVFAIL because recursor or query demands it for Bogus results"); } } } } catch (const ImmediateServFailException& e) { if (g_logCommonErrors) { - SLOG(g_log << Logger::Notice << "Sending SERVFAIL to " << comboWriter->getRemote() << " during validation of '" << comboWriter->d_mdp.d_qname << "|" << QType(comboWriter->d_mdp.d_qtype) << "' because: " << e.reason << endl, - resolver.d_slog->error(Logr::Notice, e.reason, "Sending SERVFAIL during validation", "exception", Logging::Loggable("ImmediateServFailException"))); + resolver.d_slog->error(Logr::Notice, e.reason, "Sending SERVFAIL during validation", "exception", Logging::Loggable("ImmediateServFailException")); } goto sendit; // NOLINT(cppcoreguidelines-avoid-goto) } catch (const pdns::validation::TooManySEC3IterationsException& e) { if (g_logCommonErrors || (g_dnssecLogBogus && resolver.getDNSSECLimitHit())) { - SLOG(g_log << Logger::Notice << "Sending SERVFAIL to " << comboWriter->getRemote() << " during validation of '" << comboWriter->d_mdp.d_qname << "|" << QType(comboWriter->d_mdp.d_qtype) << "' because: " << e.what() << endl, - resolver.d_slog->error(Logr::Notice, e.what(), "Sending SERVFAIL during validation", "exception", Logging::Loggable("TooManySEC3IterationsException"), "dnsseclimithit", Logging::Loggable(resolver.getDNSSECLimitHit()))); + resolver.d_slog->error(Logr::Notice, e.what(), "Sending SERVFAIL during validation", "exception", Logging::Loggable("TooManySEC3IterationsException"), "dnsseclimithit", Logging::Loggable(resolver.getDNSSECLimitHit())); } goto sendit; // NOLINT(cppcoreguidelines-avoid-goto) } @@ -1815,9 +1792,7 @@ void startDoResolve(void* arg) // NOLINT(readability-function-cognitive-complexi } int sendErr = sendOnNBSocket(comboWriter->d_socket, &msgh); if (sendErr != 0 && g_logCommonErrors) { - SLOG(g_log << Logger::Warning << "Sending UDP reply to client " << comboWriter->getRemote() << " failed with: " - << stringerror(sendErr) << endl, - g_slogudpin->error(Logr::Warning, sendErr, "Sending UDP reply to client failed")); + g_slogudpin->error(Logr::Warning, sendErr, "Sending UDP reply to client failed"); } } else { @@ -1896,8 +1871,7 @@ void startDoResolve(void* arg) // NOLINT(readability-function-cognitive-complexi } if (resolver.d_eventTrace.enabled() && SyncRes::eventTraceEnabled(SyncRes::event_trace_to_log)) { - SLOG(g_log << Logger::Info << resolver.d_eventTrace.toString() << endl, - resolver.d_slog->info(Logr::Info, resolver.d_eventTrace.toString())); // Maybe we want it to be more fancy? + resolver.d_slog->info(Logr::Info, resolver.d_eventTrace.toString()); // Maybe we want it to be more fancy? } // Originally this code used a mix of floats, doubles, uint64_t with different units. @@ -1967,24 +1941,20 @@ void startDoResolve(void* arg) // NOLINT(readability-function-cognitive-complexi // cout<d_mdp.d_qname<<"\t"<getUsec()<<"\t"<error(Logr::Error, ae.reason, "startDoResolve problem", "exception", Logging::Loggable("PDNSException"))); + resolver.d_slog->error(Logr::Error, ae.reason, "startDoResolve problem", "exception", Logging::Loggable("PDNSException")); } catch (const MOADNSException& mde) { - SLOG(g_log << Logger::Error << "DNS parser error " << makeLoginfo(comboWriter) << ": " << comboWriter->d_mdp.d_qname << ", " << mde.what() << endl, - resolver.d_slog->error(Logr::Error, mde.what(), "DNS parser error")); + resolver.d_slog->error(Logr::Error, mde.what(), "DNS parser error"); } catch (const std::exception& e) { - SLOG(g_log << Logger::Error << "STL error " << makeLoginfo(comboWriter) << ": " << e.what(), - resolver.d_slog->error(Logr::Error, e.what(), "Exception in resolver context", "exception", Logging::Loggable("std::exception"))); + resolver.d_slog->error(Logr::Error, e.what(), "Exception in resolver context", "exception", Logging::Loggable("std::exception")); // Luawrapper nests the exception from Lua, so we unnest it here try { std::rethrow_if_nested(e); } catch (const std::exception& ne) { - SLOG(g_log << ". Extra info: " << ne.what(), - resolver.d_slog->error(Logr::Error, ne.what(), "Nested exception in resolver context", Logging::Loggable("std::exception"))); + resolver.d_slog->error(Logr::Error, ne.what(), "Nested exception in resolver context", Logging::Loggable("std::exception")); } catch (...) { } @@ -1993,24 +1963,22 @@ void startDoResolve(void* arg) // NOLINT(readability-function-cognitive-complexi } } catch (...) { - SLOG(g_log << Logger::Error << "Any other exception in a resolver context " << makeLoginfo(comboWriter) << endl, - resolver.d_slog->info(Logr::Error, "Any other exception in a resolver context")); + resolver.d_slog->info(Logr::Error, "Any other exception in a resolver context"); } runTaskOnce(g_logCommonErrors); static const size_t stackSizeThreshold = 9 * ::arg().asNum("stack-size") / 10; if (g_multiTasker->getMaxStackUsage() >= stackSizeThreshold) { - SLOG(g_log << Logger::Error << "Reached mthread stack usage of 90%: " << g_multiTasker->getMaxStackUsage() << " " << makeLoginfo(comboWriter) << " after " << resolver.d_outqueries << " out queries, " << resolver.d_tcpoutqueries << " TCP out queries, " << resolver.d_dotoutqueries << " DoT out queries" << endl, - resolver.d_slog->info(Logr::Error, "Reached mthread stack usage of 90%", - "stackUsage", Logging::Loggable(g_multiTasker->getMaxStackUsage()), - "outqueries", Logging::Loggable(resolver.d_outqueries), - "netms", Logging::Loggable(resolver.d_totUsec / 1000.0), - "throttled", Logging::Loggable(resolver.d_throttledqueries), - "timeouts", Logging::Loggable(resolver.d_timeouts), - "tcpout", Logging::Loggable(resolver.d_tcpoutqueries), - "dotout", Logging::Loggable(resolver.d_dotoutqueries), - "validationState", Logging::Loggable(resolver.getValidationState()))); + resolver.d_slog->info(Logr::Error, "Reached mthread stack usage of 90%", + "stackUsage", Logging::Loggable(g_multiTasker->getMaxStackUsage()), + "outqueries", Logging::Loggable(resolver.d_outqueries), + "netms", Logging::Loggable(resolver.d_totUsec / 1000.0), + "throttled", Logging::Loggable(resolver.d_throttledqueries), + "timeouts", Logging::Loggable(resolver.d_timeouts), + "tcpout", Logging::Loggable(resolver.d_tcpoutqueries), + "dotout", Logging::Loggable(resolver.d_dotoutqueries), + "validationState", Logging::Loggable(resolver.getValidationState())); } t_Counters.at(rec::Counter::maxMThreadStackUsage) = max(g_multiTasker->getMaxStackUsage(), t_Counters.at(rec::Counter::maxMThreadStackUsage)); t_Counters.updateSnap(g_regressionTestMode); @@ -2148,8 +2116,7 @@ bool checkForCacheHit(bool qnameParsed, unsigned int tag, const string& data, static void* pleaseWipeCaches(const DNSName& canon, bool subtree, uint16_t qtype) { auto res = wipeCaches(canon, subtree, qtype); - SLOG(g_log << Logger::Info << "Wiped caches for " << canon << ": " << res.record_count << " records; " << res.negative_record_count << " negative records; " << res.packet_count << " packets" << endl, - g_slog->withName("runtime")->info(Logr::Info, "Wiped cache", "qname", Logging::Loggable(canon), "records", Logging::Loggable(res.record_count), "negrecords", Logging::Loggable(res.negative_record_count), "packets", Logging::Loggable(res.packet_count))); + g_slog->withName("runtime")->info(Logr::Info, "Wiped cache", "qname", Logging::Loggable(canon), "records", Logging::Loggable(res.record_count), "negrecords", Logging::Loggable(res.negative_record_count), "packets", Logging::Loggable(res.packet_count)); return nullptr; } @@ -2334,10 +2301,9 @@ static string* doProcessUDPQuestion(const std::string& question, const ComboAddr eventTrace.add(RecEventTrace::PCacheCheck, cacheHit, false, match); if (cacheHit) { if (!g_quiet) { - SLOG(g_log << Logger::Notice << RecThreadInfo::id() << " question answered from packet cache tag=" << ctag << " from " << source.toStringWithPort() << (source != fromaddr ? " (via " + fromaddr.toStringWithPort() + ")" : "") << endl, - g_slogudpin->info(Logr::Notice, "Question answered from packet cache", "tag", Logging::Loggable(ctag), - "qname", Logging::Loggable(qname), "qtype", Logging::Loggable(QType(qtype)), - "source", Logging::Loggable(source), "remote", Logging::Loggable(fromaddr))); + g_slogudpin->info(Logr::Notice, "Question answered from packet cache", "tag", Logging::Loggable(ctag), + "qname", Logging::Loggable(qname), "qtype", Logging::Loggable(QType(qtype)), + "source", Logging::Loggable(source), "remote", Logging::Loggable(fromaddr)); } struct msghdr msgh{}; struct iovec iov{}; @@ -2356,14 +2322,10 @@ static string* doProcessUDPQuestion(const std::string& question, const ComboAddr } if (eventTrace.enabled() && SyncRes::eventTraceEnabled(SyncRes::event_trace_to_log)) { - SLOG(g_log << Logger::Info << eventTrace.toString() << endl, - g_slogudpin->info(Logr::Info, eventTrace.toString())); // Do we want more fancy logging here? + g_slogudpin->info(Logr::Info, eventTrace.toString()); // Do we want more fancy logging here? } if (sendErr != 0 && g_logCommonErrors) { - SLOG(g_log << Logger::Warning << "Sending UDP reply to client " << source.toStringWithPort() - << (source != fromaddr ? " (via " + fromaddr.toStringWithPort() + ")" : "") << " failed with: " - << stringerror(sendErr) << endl, - g_slogudpin->error(Logr::Error, sendErr, "Sending UDP reply to client failed", "source", Logging::Loggable(source), "remote", Logging::Loggable(fromaddr))); + g_slogudpin->error(Logr::Error, sendErr, "Sending UDP reply to client failed", "source", Logging::Loggable(source), "remote", Logging::Loggable(fromaddr)); } struct timeval now{}; Utility::gettimeofday(&now, nullptr); @@ -2376,8 +2338,7 @@ static string* doProcessUDPQuestion(const std::string& question, const ComboAddr } catch (const std::exception& e) { if (g_logCommonErrors) { - SLOG(g_log << Logger::Error << "Error processing or aging answer packet: " << e.what() << endl, - g_slogudpin->error(Logr::Error, e.what(), "Error processing or aging answer packet", "exception", Logging::Loggable("std::exception"))); + g_slogudpin->error(Logr::Error, e.what(), "Error processing or aging answer packet", "exception", Logging::Loggable("std::exception")); } return nullptr; } @@ -2386,8 +2347,7 @@ static string* doProcessUDPQuestion(const std::string& question, const ComboAddr bool ipf = t_pdl->ipfilter(source, destination, *dnsheader, eventTrace); if (ipf) { if (!g_quiet) { - SLOG(g_log << Logger::Notice << RecThreadInfo::id() << " [" << g_multiTasker->getTid() << "/" << g_multiTasker->numProcesses() << "] DROPPED question from " << source.toStringWithPort() << (source != fromaddr ? " (via " + fromaddr.toStringWithPort() + ")" : "") << " based on policy" << endl, - g_slogudpin->info(Logr::Notice, "Dropped question based on policy", "source", Logging::Loggable(source), "remote", Logging::Loggable(fromaddr))); + g_slogudpin->info(Logr::Notice, "Dropped question based on policy", "source", Logging::Loggable(source), "remote", Logging::Loggable(fromaddr)); } t_Counters.at(rec::Counter::policyDrops)++; return nullptr; @@ -2397,8 +2357,7 @@ static string* doProcessUDPQuestion(const std::string& question, const ComboAddr if (dnsheader->opcode == static_cast(Opcode::Notify)) { if (!isAllowNotifyForZone(qname)) { if (!g_quiet) { - SLOG(g_log << Logger::Error << "[" << g_multiTasker->getTid() << "] dropping UDP NOTIFY from " << source.toStringWithPort() << (source != fromaddr ? " (via " + fromaddr.toStringWithPort() + ")" : "") << ", for " << qname.toLogString() << ", zone not matched by allow-notify-for" << endl, - g_slogudpin->info(Logr::Notice, "Dropping UDP NOTIFY, zone not matched by allow-notify-for", "source", Logging::Loggable(source), "remote", Logging::Loggable(fromaddr))); + g_slogudpin->info(Logr::Notice, "Dropping UDP NOTIFY, zone not matched by allow-notify-for", "source", Logging::Loggable(source), "remote", Logging::Loggable(fromaddr)); } t_Counters.at(rec::Counter::zoneDisallowedNotify)++; @@ -2406,8 +2365,7 @@ static string* doProcessUDPQuestion(const std::string& question, const ComboAddr } if (!g_quiet) { - SLOG(g_log << Logger::Notice << RecThreadInfo::id() << " got NOTIFY for " << qname.toLogString() << " from " << source.toStringWithPort() << (source != fromaddr ? " (via " + fromaddr.toStringWithPort() + ")" : "") << endl, - g_slogudpin->info(Logr::Notice, "Got NOTIFY", "source", Logging::Loggable(source), "remote", Logging::Loggable(fromaddr), "qname", Logging::Loggable(qname))); + g_slogudpin->info(Logr::Notice, "Got NOTIFY", "source", Logging::Loggable(source), "remote", Logging::Loggable(fromaddr), "qname", Logging::Loggable(qname)); } if (!ZoneXFR::notifyZoneTracker(qname)) { // It wasn't an RPZ @@ -2423,8 +2381,7 @@ static string* doProcessUDPQuestion(const std::string& question, const ComboAddr if (g_multiTasker->numProcesses() >= g_maxMThreads) { if (!g_quiet) { - SLOG(g_log << Logger::Notice << RecThreadInfo::id() << " [" << g_multiTasker->getTid() << "/" << g_multiTasker->numProcesses() << "] DROPPED question from " << source.toStringWithPort() << (source != fromaddr ? " (via " + fromaddr.toStringWithPort() + ")" : "") << ", over capacity" << endl, - g_slogudpin->info(Logr::Notice, "Dropped question, over capacity", "source", Logging::Loggable(source), "remote", Logging::Loggable(fromaddr))); + g_slogudpin->info(Logr::Notice, "Dropped question, over capacity", "source", Logging::Loggable(source), "remote", Logging::Loggable(fromaddr)); } t_Counters.at(rec::Counter::overCapacityDrops)++; return nullptr; @@ -2511,8 +2468,7 @@ static void handleNewUDPQuestion(int fileDesc, FDMultiplexer::funcparam_t& /* va if ((msgh.msg_flags & MSG_TRUNC) != 0) { t_Counters.at(rec::Counter::truncatedDrops)++; if (!g_quiet) { - SLOG(g_log << Logger::Error << "Ignoring truncated query from " << fromaddr.toString() << endl, - g_slogudpin->info(Logr::Error, "Ignoring truncated query", "remote", Logging::Loggable(fromaddr))); + g_slogudpin->info(Logr::Error, "Ignoring truncated query", "remote", Logging::Loggable(fromaddr)); } return; } @@ -2544,17 +2500,15 @@ static void handleNewUDPQuestion(int fileDesc, FDMultiplexer::funcparam_t& /* va if (used <= 0) { ++t_Counters.at(rec::Counter::proxyProtocolInvalidCount); if (!g_quiet) { - SLOG(g_log << Logger::Error << "Ignoring invalid proxy protocol (" << std::to_string(len) << ", " << std::to_string(used) << ") query from " << fromaddr.toStringWithPort() << endl, - g_slogudpin->info(Logr::Error, "Ignoring invalid proxy protocol query", "length", Logging::Loggable(len), - "used", Logging::Loggable(used), "remote", Logging::Loggable(fromaddr))); + g_slogudpin->info(Logr::Error, "Ignoring invalid proxy protocol query", "length", Logging::Loggable(len), + "used", Logging::Loggable(used), "remote", Logging::Loggable(fromaddr)); } return; } if (static_cast(used) > g_proxyProtocolMaximumSize) { if (g_quiet) { - SLOG(g_log << Logger::Error << "Proxy protocol header in UDP packet from " << fromaddr.toStringWithPort() << " is larger than proxy-protocol-maximum-size (" << used << "), dropping" << endl, - g_slogudpin->info(Logr::Error, "Proxy protocol header in UDP packet is larger than proxy-protocol-maximum-size", - "used", Logging::Loggable(used), "remote", Logging::Loggable(fromaddr))); + g_slogudpin->info(Logr::Error, "Proxy protocol header in UDP packet is larger than proxy-protocol-maximum-size", + "used", Logging::Loggable(used), "remote", Logging::Loggable(fromaddr)); } ++t_Counters.at(rec::Counter::proxyProtocolInvalidCount); return; @@ -2566,8 +2520,7 @@ static void handleNewUDPQuestion(int fileDesc, FDMultiplexer::funcparam_t& /* va /* we only allow UDP packets larger than 512 for those with a proxy protocol header */ t_Counters.at(rec::Counter::truncatedDrops)++; if (!g_quiet) { - SLOG(g_log << Logger::Error << "Ignoring truncated query from " << fromaddr.toStringWithPort() << endl, - g_slogudpin->info(Logr::Error, "Ignoring truncated query", "remote", Logging::Loggable(fromaddr))); + g_slogudpin->info(Logr::Error, "Ignoring truncated query", "remote", Logging::Loggable(fromaddr)); } return; } @@ -2575,9 +2528,8 @@ static void handleNewUDPQuestion(int fileDesc, FDMultiplexer::funcparam_t& /* va if (data.size() < sizeof(dnsheader)) { t_Counters.at(rec::Counter::ignoredCount)++; if (!g_quiet) { - SLOG(g_log << Logger::Error << "Ignoring too-short (" << std::to_string(data.size()) << ") query from " << fromaddr.toString() << endl, - g_slogudpin->info(Logr::Error, "Ignoring too-short query", "length", Logging::Loggable(data.size()), - "remote", Logging::Loggable(fromaddr))); + g_slogudpin->info(Logr::Error, "Ignoring too-short query", "length", Logging::Loggable(data.size()), + "remote", Logging::Loggable(fromaddr)); } return; } @@ -2598,8 +2550,7 @@ static void handleNewUDPQuestion(int fileDesc, FDMultiplexer::funcparam_t& /* va if (t_allowFrom && !t_allowFrom->match(&mappedSource)) { if (!g_quiet) { - SLOG(g_log << Logger::Error << "[" << g_multiTasker->getTid() << "] dropping UDP query from " << mappedSource.toString() << ", address not matched by allow-from" << endl, - g_slogudpin->info(Logr::Error, "Dropping UDP query, address not matched by allow-from", "source", Logging::Loggable(mappedSource))); + g_slogudpin->info(Logr::Error, "Dropping UDP query, address not matched by allow-from", "source", Logging::Loggable(mappedSource)); } t_Counters.at(rec::Counter::unauthorizedUDP)++; @@ -2609,8 +2560,7 @@ static void handleNewUDPQuestion(int fileDesc, FDMultiplexer::funcparam_t& /* va BOOST_STATIC_ASSERT(offsetof(sockaddr_in, sin_port) == offsetof(sockaddr_in6, sin6_port)); if (fromaddr.sin4.sin_port == 0) { // also works for IPv6 if (!g_quiet) { - SLOG(g_log << Logger::Error << "[" << g_multiTasker->getTid() << "] dropping UDP query from " << fromaddr.toStringWithPort() << ", can't deal with port 0" << endl, - g_slogudpin->info(Logr::Error, "Dropping UDP query can't deal with port 0", "remote", Logging::Loggable(fromaddr))); + g_slogudpin->info(Logr::Error, "Dropping UDP query can't deal with port 0", "remote", Logging::Loggable(fromaddr)); } t_Counters.at(rec::Counter::clientParseError)++; // not quite the best place to put it, but needs to go somewhere @@ -2624,31 +2574,27 @@ static void handleNewUDPQuestion(int fileDesc, FDMultiplexer::funcparam_t& /* va if (dnsheader->qr) { t_Counters.at(rec::Counter::ignoredCount)++; if (g_logCommonErrors) { - SLOG(g_log << Logger::Error << "Ignoring answer from " << fromaddr.toString() << " on server socket!" << endl, - g_slogudpin->info(Logr::Error, "Ignoring answer on server socket", "remote", Logging::Loggable(fromaddr))); + g_slogudpin->info(Logr::Error, "Ignoring answer on server socket", "remote", Logging::Loggable(fromaddr)); } } else if (dnsheader->opcode != static_cast(Opcode::Query) && dnsheader->opcode != static_cast(Opcode::Notify)) { t_Counters.at(rec::Counter::ignoredCount)++; if (g_logCommonErrors) { - SLOG(g_log << Logger::Error << "Ignoring unsupported opcode " << Opcode::to_s(dnsheader->opcode) << " from " << fromaddr.toString() << " on server socket!" << endl, - g_slogudpin->info(Logr::Error, "Ignoring unsupported opcode server socket", "remote", Logging::Loggable(fromaddr), "opcode", Logging::Loggable(Opcode::to_s(dnsheader->opcode)))); + g_slogudpin->info(Logr::Error, "Ignoring unsupported opcode server socket", "remote", Logging::Loggable(fromaddr), "opcode", Logging::Loggable(Opcode::to_s(dnsheader->opcode))); } } else if (dnsheader->qdcount == 0U) { t_Counters.at(rec::Counter::emptyQueriesCount)++; if (g_logCommonErrors) { - SLOG(g_log << Logger::Error << "Ignoring empty (qdcount == 0) query from " << fromaddr.toString() << " on server socket!" << endl, - g_slogudpin->info(Logr::Error, "Ignoring empty (qdcount == 0) query on server socket!", "remote", Logging::Loggable(fromaddr))); + g_slogudpin->info(Logr::Error, "Ignoring empty (qdcount == 0) query on server socket!", "remote", Logging::Loggable(fromaddr)); } } else { if (dnsheader->opcode == static_cast(Opcode::Notify)) { if (!t_allowNotifyFrom || !t_allowNotifyFrom->match(&mappedSource)) { if (!g_quiet) { - SLOG(g_log << Logger::Error << "[" << g_multiTasker->getTid() << "] dropping UDP NOTIFY from " << mappedSource.toString() << ", address not matched by allow-notify-from" << endl, - g_slogudpin->info(Logr::Error, "Dropping UDP NOTIFY from address not matched by allow-notify-from", - "source", Logging::Loggable(mappedSource))); + g_slogudpin->info(Logr::Error, "Dropping UDP NOTIFY from address not matched by allow-notify-from", + "source", Logging::Loggable(mappedSource)); } t_Counters.at(rec::Counter::sourceDisallowedNotify)++; @@ -2676,15 +2622,13 @@ static void handleNewUDPQuestion(int fileDesc, FDMultiplexer::funcparam_t& /* va catch (const MOADNSException& mde) { t_Counters.at(rec::Counter::clientParseError)++; if (g_logCommonErrors) { - SLOG(g_log << Logger::Error << "Unable to parse packet from remote UDP client " << fromaddr.toString() << ": " << mde.what() << endl, - g_slogudpin->error(Logr::Error, mde.what(), "Unable to parse packet from remote UDP client", "remote", Logging::Loggable(fromaddr), "exception", Logging::Loggable("MOADNSException"))); + g_slogudpin->error(Logr::Error, mde.what(), "Unable to parse packet from remote UDP client", "remote", Logging::Loggable(fromaddr), "exception", Logging::Loggable("MOADNSException")); } } catch (const std::runtime_error& e) { t_Counters.at(rec::Counter::clientParseError)++; if (g_logCommonErrors) { - SLOG(g_log << Logger::Error << "Unable to parse packet from remote UDP client " << fromaddr.toString() << ": " << e.what() << endl, - g_slogudpin->error(Logr::Error, e.what(), "Unable to parse packet from remote UDP client", "remote", Logging::Loggable(fromaddr), "exception", Logging::Loggable("std::runtime_error"))); + g_slogudpin->error(Logr::Error, e.what(), "Unable to parse packet from remote UDP client", "remote", Logging::Loggable(fromaddr), "exception", Logging::Loggable("std::runtime_error")); } } } @@ -2723,8 +2667,7 @@ unsigned int makeUDPServerSockets(deferredAdd_t& deferredAdds, Logr::log_t log, } if (!setSocketTimestamps(socketFd)) { - SLOG(g_log << Logger::Warning << "Unable to enable timestamp reporting for socket" << endl, - log->info(Logr::Warning, "Unable to enable timestamp reporting for socket")); + log->info(Logr::Warning, "Unable to enable timestamp reporting for socket"); } if (IsAnyAddress(address)) { if (address.sin4.sin_family == AF_INET) { @@ -2741,8 +2684,7 @@ unsigned int makeUDPServerSockets(deferredAdd_t& deferredAdds, Logr::log_t log, #endif if (address.sin6.sin6_family == AF_INET6 && setsockopt(socketFd, IPPROTO_IPV6, IPV6_V6ONLY, &one, sizeof(one)) < 0) { int err = errno; - SLOG(g_log << Logger::Warning << "Failed to set IPv6 socket to IPv6 only, continuing anyhow: " << stringerror(err) << endl, - log->error(Logr::Warning, err, "Failed to set IPv6 socket to IPv6 only, continuing anyhow")); + log->error(Logr::Warning, err, "Failed to set IPv6 socket to IPv6 only, continuing anyhow"); } } if (::arg().mustDo("non-local-bind")) { @@ -2755,8 +2697,7 @@ unsigned int makeUDPServerSockets(deferredAdd_t& deferredAdds, Logr::log_t log, setSocketReceiveBuffer(socketFd, 250000); } catch (const std::exception& e) { - SLOG(g_log << Logger::Error << e.what() << endl, - log->error(Logr::Error, e.what(), "Exception while setting socket buffer size")); + log->error(Logr::Error, e.what(), "Exception while setting socket buffer size"); } if (g_reusePort) { @@ -2781,8 +2722,7 @@ unsigned int makeUDPServerSockets(deferredAdd_t& deferredAdds, Logr::log_t log, setSocketIgnorePMTU(socketFd, address.sin4.sin_family); } catch (const std::exception& e) { - SLOG(g_log << Logger::Warning << "Failed to set IP_MTU_DISCOVER on UDP server socket: " << e.what() << endl, - log->error(Logr::Warning, e.what(), "Failed to set IP_MTU_DISCOVER on UDP server socket")); + log->error(Logr::Warning, e.what(), "Failed to set IP_MTU_DISCOVER on UDP server socket"); } socklen_t socklen = address.getSocklen(); @@ -2812,8 +2752,7 @@ static bool trySendingQueryToWorker(unsigned int target, ThreadMSG* tmsg) { auto& targetInfo = RecThreadInfo::info(target); if (!targetInfo.isWorker()) { - SLOG(g_log << Logger::Error << "distributeAsyncFunction() tried to assign a query to a non-worker thread" << endl, - g_slog->withName("runtime")->info(Logr::Error, "distributeAsyncFunction() tried to assign a query to a non-worker thread")); + g_slog->withName("runtime")->info(Logr::Error, "distributeAsyncFunction() tried to assign a query to a non-worker thread"); _exit(1); } @@ -2880,8 +2819,7 @@ static unsigned int selectWorker(unsigned int hash) void distributeAsyncFunction(const string& packet, const pipefunc_t& func) { if (!RecThreadInfo::self().isDistributor()) { - SLOG(g_log << Logger::Error << "distributeAsyncFunction() has been called by a worker (" << RecThreadInfo::id() << ")" << endl, - g_slog->withName("runtime")->info(Logr::Error, "distributeAsyncFunction() has been called by a worker")); // tid will be added + g_slog->withName("runtime")->info(Logr::Error, "distributeAsyncFunction() has been called by a worker"); // tid will be added _exit(1); } @@ -3006,8 +2944,7 @@ static void handleUDPServerResponse(int fileDesc, FDMultiplexer::funcparam_t& va // Drop it, but continue to wait for other packets t_Counters.at(rec::Counter::serverParseError)++; if (g_logCommonErrors) { - SLOG(g_log << Logger::Error << "Unable to parse too short packet from remote UDP server " << fromaddr.toString() << ": packet smaller than DNS header" << endl, - g_slogout->info(Logr::Error, "Unable to parse too short packet from remote UDP server", "from", Logging::Loggable(fromaddr))); + g_slogout->info(Logr::Error, "Unable to parse too short packet from remote UDP server", "from", Logging::Loggable(fromaddr)); } return; } @@ -3023,8 +2960,7 @@ static void handleUDPServerResponse(int fileDesc, FDMultiplexer::funcparam_t& va pident->fd = fileDesc; if (!dnsheader.qr && g_logCommonErrors) { - SLOG(g_log << Logger::Notice << "Not taking data from question on outgoing socket from " << fromaddr.toStringWithPort() << endl, - g_slogout->info(Logr::Error, "Not taking data from question on outgoing socket", "from", Logging::Loggable(fromaddr))); + g_slogout->info(Logr::Error, "Not taking data from question on outgoing socket", "from", Logging::Loggable(fromaddr)); } if (dnsheader.qdcount == 0U || // UPC, Nominum, very old BIND on FormErr, NSD @@ -3047,8 +2983,7 @@ static void handleUDPServerResponse(int fileDesc, FDMultiplexer::funcparam_t& va catch (std::exception& e) { // Parse error, continue waiting for other packets t_Counters.at(rec::Counter::serverParseError)++; // won't be fed to lwres.cc, so we have to increment - SLOG(g_log << Logger::Warning << "Error in packet from remote nameserver " << fromaddr.toStringWithPort() << ": " << e.what() << endl, - g_slogudpin->error(Logr::Warning, e.what(), "Error in packet from remote nameserver", "from", Logging::Loggable(fromaddr))); + g_slogudpin->error(Logr::Warning, e.what(), "Error in packet from remote nameserver", "from", Logging::Loggable(fromaddr)); return; } } @@ -3083,11 +3018,10 @@ retryWithName: } t_Counters.at(rec::Counter::unexpectedCount)++; // if we made it here, it really is an unexpected answer if (g_logCommonErrors) { - SLOG(g_log << Logger::Warning << "Discarding unexpected packet from " << fromaddr.toStringWithPort() << ": " << (pident->domain.empty() ? "" : pident->domain.toString()) << ", " << pident->type << ", " << g_multiTasker->getWaiters().size() << " waiters" << endl, - g_slogudpin->info(Logr::Warning, "Discarding unexpected packet", "from", Logging::Loggable(fromaddr), - "qname", Logging::Loggable(pident->domain), - "qtype", Logging::Loggable(QType(pident->type)), - "waiters", Logging::Loggable(g_multiTasker->getWaiters().size()))); + g_slogudpin->info(Logr::Warning, "Discarding unexpected packet", "from", Logging::Loggable(fromaddr), + "qname", Logging::Loggable(pident->domain), + "qtype", Logging::Loggable(QType(pident->type)), + "waiters", Logging::Loggable(g_multiTasker->getWaiters().size())); } } else if (fileDesc >= 0) { diff --git a/pdns/recursordist/pubsuffixloader.cc b/pdns/recursordist/pubsuffixloader.cc index 1174a82c5..5fd3150f5 100644 --- a/pdns/recursordist/pubsuffixloader.cc +++ b/pdns/recursordist/pubsuffixloader.cc @@ -67,13 +67,11 @@ void initPublicSuffixList(const std::string& file) } } - SLOG(g_log << Logger::Info << "Loaded the Public Suffix List from '" << file << "'" << endl, - g_slog->withName("runtime")->info(Logr::Info, "Loaded the Public Suffix List", "file", Logging::Loggable(file))); + g_slog->withName("runtime")->info(Logr::Info, "Loaded the Public Suffix List", "file", Logging::Loggable(file)); loaded = true; } catch (const std::exception& e) { - SLOG(g_log << Logger::Warning << "Error while loading the Public Suffix List from '" << file << "', falling back to the built-in list: " << e.what() << endl, - g_slog->withName("runtime")->error(Logr::Error, e.what(), "Error while loading the Public Suffix List", "file", Logging::Loggable(file))); + g_slog->withName("runtime")->error(Logr::Error, e.what(), "Error while loading the Public Suffix List", "file", Logging::Loggable(file)); } } diff --git a/pdns/recursordist/ratelimitedlog.hh b/pdns/recursordist/ratelimitedlog.hh index 568cbda66..4db2cec48 100644 --- a/pdns/recursordist/ratelimitedlog.hh +++ b/pdns/recursordist/ratelimitedlog.hh @@ -37,10 +37,9 @@ public: { uint32_t count{}; if (doLog(count)) { - SLOG(g_log << Logger::Error << msg << " created an exception" << endl, - slog->info(Logr::Error, msg + " created an exception", - "ratelimitingSkipped", Logging::Loggable(count), - "exception", Logging::Loggable("other"), args...)); + slog->info(Logr::Error, msg + " created an exception", + "ratelimitingSkipped", Logging::Loggable(count), + "exception", Logging::Loggable("other"), args...); }; } @@ -49,10 +48,9 @@ public: { uint32_t count{}; if (doLog(count)) { - SLOG(g_log << Logger::Error << msg << " created an exception: " << stdException.what() << endl, - slog->error(Logr::Error, stdException.what(), msg + " created an exception", - "ratelimitingSkipped", Logging::Loggable(count), - "exception", Logging::Loggable("std::exception"), args...)); + slog->error(Logr::Error, stdException.what(), msg + " created an exception", + "ratelimitingSkipped", Logging::Loggable(count), + "exception", Logging::Loggable("std::exception"), args...); } } @@ -61,10 +59,9 @@ public: { uint32_t count{}; if (doLog(count)) { - SLOG(g_log << Logger::Error << msg << " created an PDNSException: " << pdnsException.reason << endl, - slog->error(Logr::Error, pdnsException.reason, msg + " created an exception", - "ratelimitingSkipped", Logging::Loggable(count), - "exception", Logging::Loggable("PDNSException"), args...)); + slog->error(Logr::Error, pdnsException.reason, msg + " created an exception", + "ratelimitingSkipped", Logging::Loggable(count), + "exception", Logging::Loggable("PDNSException"), args...); } } diff --git a/pdns/recursordist/rec-carbon.cc b/pdns/recursordist/rec-carbon.cc index 1eecf86c5..525738a41 100644 --- a/pdns/recursordist/rec-carbon.cc +++ b/pdns/recursordist/rec-carbon.cc @@ -65,27 +65,22 @@ void doCarbonDump(void*) auto ret = asendtcp(msg, handler); // this will actually do the right thing waiting on the connect if (ret == LWResult::Result::Timeout) { - SLOG(g_log << Logger::Warning << "Timeout connecting/writing carbon data to " << remote.toStringWithPort() << endl, - log->info(Logr::Warning, "Timeout connecting/writing carbon data", "address", Logging::Loggable(remote))); + log->info(Logr::Warning, "Timeout connecting/writing carbon data", "address", Logging::Loggable(remote)); } else if (ret != LWResult::Result::Success) { int err = errno; - SLOG(g_log << Logger::Warning << "Error writing carbon data to " << remote.toStringWithPort() << ": " << stringerror(err) << endl, - log->error(Logr::Warning, err, "Error writing carbon data", "address", Logging::Loggable(remote))); + log->error(Logr::Warning, err, "Error writing carbon data", "address", Logging::Loggable(remote)); } handler->close(); } } catch (const PDNSException& e) { - SLOG(g_log << Logger::Error << "Error in carbon thread: " << e.reason << endl, - log->error(Logr::Error, e.reason, "Error in carbon thread", "exception", Logging::Loggable("PDNSException"))); + log->error(Logr::Error, e.reason, "Error in carbon thread", "exception", Logging::Loggable("PDNSException")); } catch (const std::exception& e) { - SLOG(g_log << Logger::Error << "Error in carbon thread: " << e.what() << endl, - log->error(Logr::Error, e.what(), "Error in carbon thread", "exception", Logging::Loggable("std::exception"))); + log->error(Logr::Error, e.what(), "Error in carbon thread", "exception", Logging::Loggable("std::exception")); } catch (...) { - SLOG(g_log << Logger::Error << "Unknown error in carbon thread" << endl, - log->info(Logr::Error, "Error in carbon thread")); + log->info(Logr::Error, "Error in carbon thread"); } } diff --git a/pdns/recursordist/rec-lua-conf.cc b/pdns/recursordist/rec-lua-conf.cc index d4a84532c..d8a092a79 100644 --- a/pdns/recursordist/rec-lua-conf.cc +++ b/pdns/recursordist/rec-lua-conf.cc @@ -302,8 +302,7 @@ static void rpzPrimary(LuaConfigItems& lci, const boost::variant(have.at("refresh")); if (params.zoneXFRParams.refreshFromConf == 0) { - SLOG(g_log << Logger::Warning << "rpzPrimary refresh value of 0 ignored" << endl, - lci.d_slog->info(Logr::Warning, "rpzPrimary refresh value of 0 ignored")); + lci.d_slog->info(Logr::Warning, "rpzPrimary refresh value of 0 ignored"); } } @@ -340,12 +339,10 @@ static void rpzPrimary(LuaConfigItems& lci, const boost::varianterror(Logr::Error, e.what(), "Exception configuring 'rpzPrimary'", "exception", Logging::Loggable("std::exception"))); + lci.d_slog->error(Logr::Error, e.what(), "Exception configuring 'rpzPrimary'", "exception", Logging::Loggable("std::exception")); } catch (const PDNSException& e) { - SLOG(g_log << Logger::Error << "Problem configuring 'rpzPrimary': " << e.reason << endl, - lci.d_slog->error(Logr::Error, e.reason, "Exception configuring 'rpzPrimary'", Logging::Loggable("PDNSException"))); + lci.d_slog->error(Logr::Error, e.reason, "Exception configuring 'rpzPrimary'", Logging::Loggable("PDNSException")); } } @@ -423,8 +420,7 @@ void loadRecursorLuaConfig(const std::string& fname, ProxyMapping& proxyMapping, }); Lua->writeFunction("rpzMaster", [&lci](const boost::variant>>& primaries_, const string& zoneName, const boost::optional& options) { - SLOG(g_log << Logger::Warning << "'rpzMaster' is deprecated and will be removed in a future release, use 'rpzPrimary' instead" << endl, - lci.d_slog->info(Logr::Warning, "'rpzMaster' is deprecated and will be removed in a future release, use 'rpzPrimary' instead")); + lci.d_slog->info(Logr::Warning, "'rpzMaster' is deprecated and will be removed in a future release, use 'rpzPrimary' instead"); rpzPrimary(lci, primaries_, zoneName, options); }); Lua->writeFunction("rpzPrimary", [&lci](const boost::variant>>& primaries_, const string& zoneName, const boost::optional& options) { @@ -509,9 +505,8 @@ void loadRecursorLuaConfig(const std::string& fname, ProxyMapping& proxyMapping, lci.ztcConfigs[validZoneName] = std::move(conf); } catch (const std::exception& e) { - SLOG(g_log << Logger::Error << "Problem configuring zoneToCache for zone '" << zoneName << "': " << e.what() << endl, - lci.d_slog->error(Logr::Error, e.what(), "Problem configuring zoneToCache", "zone", Logging::Loggable(zoneName), - "exception", Logging::Loggable("std::exception"))); + lci.d_slog->error(Logr::Error, e.what(), "Problem configuring zoneToCache", "zone", Logging::Loggable(zoneName), + "exception", Logging::Loggable("std::exception")); } }); @@ -542,8 +537,7 @@ void loadRecursorLuaConfig(const std::string& fname, ProxyMapping& proxyMapping, } } catch (std::exception& e) { - SLOG(g_log << Logger::Error << "Error in addSortList: " << e.what() << endl, - lci.d_slog->error(Logr::Error, e.what(), "Error in addSortList", "exception", Logging::Loggable("std::exception"))); + lci.d_slog->error(Logr::Error, e.what(), "Error in addSortList", "exception", Logging::Loggable("std::exception")); } }); @@ -562,8 +556,7 @@ void loadRecursorLuaConfig(const std::string& fname, ProxyMapping& proxyMapping, /* Remove in 4.3 */ Lua->writeFunction("addDS", [&lci](const std::string& who, const std::string& what) { - SLOG(g_log << Logger::Warning << "addDS is deprecated and will be removed in the future, switch to addTA" << endl, - lci.d_slog->info(Logr::Warning, "addDS is deprecated and will be removed in the future, switch to addTA")); + lci.d_slog->info(Logr::Warning, "addDS is deprecated and will be removed in the future, switch to addTA"); DNSName zone(who); auto ds = std::dynamic_pointer_cast(DSRecordContent::make(what)); lci.dsAnchors[zone].insert(*ds); @@ -571,8 +564,7 @@ void loadRecursorLuaConfig(const std::string& fname, ProxyMapping& proxyMapping, /* Remove in 4.3 */ Lua->writeFunction("clearDS", [&lci](boost::optional who) { - SLOG(g_log << Logger::Warning << "clearDS is deprecated and will be removed in the future, switch to clearTA" << endl, - lci.d_slog->info(Logr::Warning, "clearDS is deprecated and will be removed in the future, switch to clearTA")); + lci.d_slog->info(Logr::Warning, "clearDS is deprecated and will be removed in the future, switch to clearTA"); if (who) lci.dsAnchors.erase(DNSName(*who)); else @@ -628,17 +620,14 @@ void loadRecursorLuaConfig(const std::string& fname, ProxyMapping& proxyMapping, parseProtobufOptions(vars, lci.protobufExportConfig); } catch (std::exception& e) { - SLOG(g_log << Logger::Error << "Error while adding protobuf logger: " << e.what() << endl, - lci.d_slog->error(Logr::Error, e.what(), "Exception while adding protobuf logger", "exception", Logging::Loggable("std::exception"))); + lci.d_slog->error(Logr::Error, e.what(), "Exception while adding protobuf logger", "exception", Logging::Loggable("std::exception")); } catch (PDNSException& e) { - SLOG(g_log << Logger::Error << "Error while adding protobuf logger: " << e.reason << endl, - lci.d_slog->error(Logr::Error, e.reason, "Exception while adding protobuf logger", "exception", Logging::Loggable("PDNSException"))); + lci.d_slog->error(Logr::Error, e.reason, "Exception while adding protobuf logger", "exception", Logging::Loggable("PDNSException")); } } else { - SLOG(g_log << Logger::Error << "Only one protobufServer() directive can be configured, we already have " << lci.protobufExportConfig.servers.at(0).toString() << endl, - lci.d_slog->info(Logr::Error, "Only one protobufServer() directive can be configured", "existing", Logging::Loggable(lci.protobufExportConfig.servers.at(0).toString()))); + lci.d_slog->info(Logr::Error, "Only one protobufServer() directive can be configured", "existing", Logging::Loggable(lci.protobufExportConfig.servers.at(0).toString())); } }); @@ -663,17 +652,14 @@ void loadRecursorLuaConfig(const std::string& fname, ProxyMapping& proxyMapping, parseProtobufOptions(vars, lci.outgoingProtobufExportConfig); } catch (std::exception& e) { - SLOG(g_log << Logger::Error << "Error while starting outgoing protobuf logger: " << e.what() << endl, - lci.d_slog->error(Logr::Error, "Exception while starting outgoing protobuf logger", "exception", Logging::Loggable("std::exception"))); + lci.d_slog->error(Logr::Error, "Exception while starting outgoing protobuf logger", "exception", Logging::Loggable("std::exception")); } catch (PDNSException& e) { - SLOG(g_log << Logger::Error << "Error while starting outgoing protobuf logger: " << e.reason << endl, - lci.d_slog->error(Logr::Error, "Exception while starting outgoing protobuf logger", "exception", Logging::Loggable("PDNSException"))); + lci.d_slog->error(Logr::Error, "Exception while starting outgoing protobuf logger", "exception", Logging::Loggable("PDNSException")); } } else { - SLOG(g_log << Logger::Error << "Only one outgoingProtobufServer() directive can be configured, we already have " << lci.outgoingProtobufExportConfig.servers.at(0).toString() << endl, - lci.d_slog->info(Logr::Error, "Only one outgoingProtobufServer() directive can be configured", "existing", Logging::Loggable(lci.outgoingProtobufExportConfig.servers.at(0).toString()))); + lci.d_slog->info(Logr::Error, "Only one outgoingProtobufServer() directive can be configured", "existing", Logging::Loggable(lci.outgoingProtobufExportConfig.servers.at(0).toString())); } }); @@ -701,17 +687,14 @@ void loadRecursorLuaConfig(const std::string& fname, ProxyMapping& proxyMapping, parseFrameStreamOptions(vars, lci.frameStreamExportConfig); } catch (std::exception& e) { - SLOG(g_log << Logger::Error << "Error reading config for dnstap framestream logger: " << e.what() << endl, - lci.d_slog->error(Logr::Error, "Exception reading config for dnstap framestream logger", "exception", Logging::Loggable("std::exception"))); + lci.d_slog->error(Logr::Error, "Exception reading config for dnstap framestream logger", "exception", Logging::Loggable("std::exception")); } catch (PDNSException& e) { - SLOG(g_log << Logger::Error << "Error reading config for dnstap framestream logger: " << e.reason << endl, - lci.d_slog->error(Logr::Error, "Exception reading config for dnstap framestream logger", "exception", Logging::Loggable("PDNSException"))); + lci.d_slog->error(Logr::Error, "Exception reading config for dnstap framestream logger", "exception", Logging::Loggable("PDNSException")); } } else { - SLOG(g_log << Logger::Error << "Only one dnstapFrameStreamServer() directive can be configured, we already have " << lci.frameStreamExportConfig.servers.at(0) << endl, - lci.d_slog->info(Logr::Error, "Only one dnstapFrameStreamServer() directive can be configured", "existing", Logging::Loggable(lci.frameStreamExportConfig.servers.at(0)))); + lci.d_slog->info(Logr::Error, "Only one dnstapFrameStreamServer() directive can be configured", "existing", Logging::Loggable(lci.frameStreamExportConfig.servers.at(0))); } }); Lua->writeFunction("dnstapNODFrameStreamServer", [&lci](boost::variant> servers, boost::optional vars) { @@ -736,17 +719,14 @@ void loadRecursorLuaConfig(const std::string& fname, ProxyMapping& proxyMapping, parseFrameStreamOptions(vars, lci.nodFrameStreamExportConfig); } catch (std::exception& e) { - SLOG(g_log << Logger::Error << "Error reading config for dnstap NOD framestream logger: " << e.what() << endl, - lci.d_slog->error(Logr::Error, "Exception reading config for dnstap NOD framestream logger", "exception", Logging::Loggable("std::exception"))); + lci.d_slog->error(Logr::Error, "Exception reading config for dnstap NOD framestream logger", "exception", Logging::Loggable("std::exception")); } catch (PDNSException& e) { - SLOG(g_log << Logger::Error << "Error reading config for dnstap NOD framestream logger: " << e.reason << endl, - lci.d_slog->error(Logr::Error, "Exception reading config for dnstap NOD framestream logger", "exception", Logging::Loggable("PDNSException"))); + lci.d_slog->error(Logr::Error, "Exception reading config for dnstap NOD framestream logger", "exception", Logging::Loggable("PDNSException")); } } else { - SLOG(g_log << Logger::Error << "Only one dnstapNODFrameStreamServer() directive can be configured, we already have " << lci.nodFrameStreamExportConfig.servers.at(0) << endl, - lci.d_slog->info(Logr::Error, "Only one dnstapNODFrameStreamServer() directive can be configured", "existing", Logging::Loggable(lci.nodFrameStreamExportConfig.servers.at(0)))); + lci.d_slog->info(Logr::Error, "Only one dnstapNODFrameStreamServer() directive can be configured", "existing", Logging::Loggable(lci.nodFrameStreamExportConfig.servers.at(0))); } }); #endif /* HAVE_FSTRM */ @@ -760,8 +740,7 @@ void loadRecursorLuaConfig(const std::string& fname, ProxyMapping& proxyMapping, case QType::NAPTR: break; default: - SLOG(g_log << Logger::Error << "addAllowedAdditionalQType does not support " << QType(qtype).toString() << endl, - lci.d_slog->info(Logr::Error, "addAllowedAdditionalQType does not support this qtype", "qtype", Logging::Loggable(QType(qtype).toString()))); + lci.d_slog->info(Logr::Error, "addAllowedAdditionalQType does not support this qtype", "qtype", Logging::Loggable(QType(qtype).toString())); return; } @@ -776,8 +755,7 @@ void loadRecursorLuaConfig(const std::string& fname, ProxyMapping& proxyMapping, if (const auto it = options->find("mode"); it != options->end()) { mode = static_cast(it->second); if (mode > AdditionalMode::ResolveDeferred) { - SLOG(g_log << Logger::Error << "addAllowedAdditionalQType: unknown mode " << it->second << endl, - lci.d_slog->info(Logr::Error, "addAllowedAdditionalQType: unknown mode", "mode", Logging::Loggable( it->second))); + lci.d_slog->info(Logr::Error, "addAllowedAdditionalQType: unknown mode", "mode", Logging::Loggable( it->second)); } } } @@ -798,12 +776,10 @@ void loadRecursorLuaConfig(const std::string& fname, ProxyMapping& proxyMapping, proxyMapping.insert_or_assign(netmask, {address, smn}); } catch (std::exception& e) { - SLOG(g_log << Logger::Error << "Error processing addProxyMapping: " << e.what() << endl, - lci.d_slog->error(Logr::Error, e.what(), "Exception processing addProxyMapping", "exception", Logging::Loggable("std::exception"))); + lci.d_slog->error(Logr::Error, e.what(), "Exception processing addProxyMapping", "exception", Logging::Loggable("std::exception")); } catch (PDNSException& e) { - SLOG(g_log << Logger::Error << "Error processing addProxyMapping: " << e.reason << endl, - lci.d_slog->error(Logr::Error, e.reason, "Exception processing addProxyMapping", "exception", Logging::Loggable("PDNSException"))); + lci.d_slog->error(Logr::Error, e.reason, "Exception processing addProxyMapping", "exception", Logging::Loggable("PDNSException")); } }); @@ -812,26 +788,22 @@ void loadRecursorLuaConfig(const std::string& fname, ProxyMapping& proxyMapping, newLuaConfig = std::move(lci); } catch (const LuaContext::ExecutionErrorException& e) { - SLOG(g_log << Logger::Error << "Unable to load Lua script from '" + fname + "': ", - lci.d_slog->error(Logr::Error, e.what(), "Unable to load Lua script", "file", Logging::Loggable(fname))); + lci.d_slog->error(Logr::Error, e.what(), "Unable to load Lua script", "file", Logging::Loggable(fname)); try { std::rethrow_if_nested(e); } catch (const std::exception& exp) { // exp is the exception that was thrown from inside the lambda - SLOG(g_log << exp.what() << std::endl, - lci.d_slog->error(Logr::Error, exp.what(), "Exception loading Lua", "exception", Logging::Loggable("std::exception"))); + lci.d_slog->error(Logr::Error, exp.what(), "Exception loading Lua", "exception", Logging::Loggable("std::exception")); } catch (const PDNSException& exp) { // exp is the exception that was thrown from inside the lambda - SLOG(g_log << exp.reason << std::endl, - lci.d_slog->error(Logr::Error, exp.reason, "Exception loading Lua", "exception", Logging::Loggable("PDNSException"))); + lci.d_slog->error(Logr::Error, exp.reason, "Exception loading Lua", "exception", Logging::Loggable("PDNSException")); } throw; } catch (std::exception& err) { - SLOG(g_log << Logger::Error << "Unable to load Lua script from '" + fname + "': " << err.what() << endl, - lci.d_slog->error(Logr::Error, err.what(), "Unable to load Lua script", "file", Logging::Loggable(fname), "exception", Logging::Loggable("std::exception"))); + lci.d_slog->error(Logr::Error, err.what(), "Unable to load Lua script", "file", Logging::Loggable(fname), "exception", Logging::Loggable("std::exception")); throw; } } diff --git a/pdns/recursordist/rec-main.cc b/pdns/recursordist/rec-main.cc index 457005e68..52669e277 100644 --- a/pdns/recursordist/rec-main.cc +++ b/pdns/recursordist/rec-main.cc @@ -156,8 +156,7 @@ static std::map> parseCPUMap(Logr::log_t log) const std::string value = ::arg()["cpu-map"]; if (!value.empty() && !isSettingThreadCPUAffinitySupported()) { - SLOG(g_log << Logger::Warning << "CPU mapping requested but not supported, skipping" << endl, - log->info(Logr::Warning, "CPU mapping requested but not supported, skipping")); + log->info(Logr::Warning, "CPU mapping requested but not supported, skipping"); return result; } @@ -187,8 +186,7 @@ static std::map> parseCPUMap(Logr::log_t log) } } catch (const std::exception& e) { - SLOG(g_log << Logger::Error << "Error parsing cpu-map entry '" << part << "': " << e.what() << endl, - log->error(Logr::Error, e.what(), "Error parsing cpu-map entry", "entry", Logging::Loggable(part))); + log->error(Logr::Error, e.what(), "Error parsing cpu-map entry", "entry", Logging::Loggable(part)); } } @@ -248,8 +246,7 @@ int RecThreadInfo::runThreads(Logr::log_t log) const auto cpusMap = parseCPUMap(log); if (RecThreadInfo::numDistributors() + RecThreadInfo::numUDPWorkers() == 1) { - SLOG(g_log << Logger::Warning << "Operating with single UDP distributor/worker thread" << endl, - log->info(Logr::Notice, "Operating with single UDP distributor/worker thread")); + log->info(Logr::Notice, "Operating with single UDP distributor/worker thread"); /* This thread handles the web server, carbon, statistics and the control channel */ unsigned int currentThreadId = 0; @@ -319,23 +316,20 @@ int RecThreadInfo::runThreads(Logr::log_t log) // And now start the actual threads currentThreadId = 1; if (RecThreadInfo::weDistributeQueries()) { - SLOG(g_log << Logger::Warning << "Launching " << RecThreadInfo::numDistributors() << " distributor threads" << endl, - log->info(Logr::Notice, "Launching distributor threads", "count", Logging::Loggable(RecThreadInfo::numDistributors()))); + log->info(Logr::Notice, "Launching distributor threads", "count", Logging::Loggable(RecThreadInfo::numDistributors())); for (unsigned int thread = 0; thread < RecThreadInfo::numDistributors(); thread++, currentThreadId++) { auto& info = RecThreadInfo::info(currentThreadId); info.start(currentThreadId, "distr", cpusMap, log); } } - SLOG(g_log << Logger::Warning << "Launching " << RecThreadInfo::numUDPWorkers() << " worker threads" << endl, - log->info(Logr::Notice, "Launching worker threads", "count", Logging::Loggable(RecThreadInfo::numUDPWorkers()))); + log->info(Logr::Notice, "Launching worker threads", "count", Logging::Loggable(RecThreadInfo::numUDPWorkers())); for (unsigned int thread = 0; thread < RecThreadInfo::numUDPWorkers(); thread++, currentThreadId++) { auto& info = RecThreadInfo::info(currentThreadId); info.start(currentThreadId, "worker", cpusMap, log); } - SLOG(g_log << Logger::Warning << "Launching " << RecThreadInfo::numTCPWorkers() << " tcpworker threads" << endl, - log->info(Logr::Notice, "Launching tcpworker threads", "count", Logging::Loggable(RecThreadInfo::numTCPWorkers()))); + log->info(Logr::Notice, "Launching tcpworker threads", "count", Logging::Loggable(RecThreadInfo::numTCPWorkers())); for (unsigned int thread = 0; thread < RecThreadInfo::numTCPWorkers(); thread++, currentThreadId++) { auto& info = RecThreadInfo::info(currentThreadId); @@ -374,8 +368,7 @@ void RecThreadInfo::makeThreadPipes(Logr::log_t log) { auto pipeBufferSize = ::arg().asNum("distribution-pipe-buffer-size"); if (pipeBufferSize > 0) { - SLOG(g_log << Logger::Info << "Resizing the buffer of the distribution pipe to " << pipeBufferSize << endl, - log->info(Logr::Info, "Resizing the buffer of the distribution pipe", "size", Logging::Loggable(pipeBufferSize))); + log->info(Logr::Info, "Resizing the buffer of the distribution pipe", "size", Logging::Loggable(pipeBufferSize)); } /* thread 0 is the handler / SNMP, worker threads start at 1 */ @@ -412,12 +405,10 @@ void RecThreadInfo::makeThreadPipes(Logr::log_t log) if (pipeBufferSize > 0) { if (!setPipeBufferSize(threadInfo.pipes.writeQueriesToThread, pipeBufferSize)) { int err = errno; - SLOG(g_log << Logger::Warning << "Error resizing the buffer of the distribution pipe for thread " << thread << " to " << pipeBufferSize << ": " << stringerror(err) << endl, - log->error(Logr::Warning, err, "Error resizing the buffer of the distribution pipe for thread", "thread", Logging::Loggable(thread), "size", Logging::Loggable(pipeBufferSize))); + log->error(Logr::Warning, err, "Error resizing the buffer of the distribution pipe for thread", "thread", Logging::Loggable(thread), "size", Logging::Loggable(pipeBufferSize)); auto existingSize = getPipeBufferSize(threadInfo.pipes.writeQueriesToThread); if (existingSize > 0) { - SLOG(g_log << Logger::Warning << "The current size of the distribution pipe's buffer for thread " << thread << " is " << existingSize << endl, - log->info(Logr::Warning, "The current size of the distribution pipe's buffer for thread", "thread", Logging::Loggable(thread), "size", Logging::Loggable(existingSize))); + log->info(Logr::Warning, "The current size of the distribution pipe's buffer for thread", "thread", Logging::Loggable(thread), "size", Logging::Loggable(existingSize)); } } } @@ -443,16 +434,13 @@ static FDMultiplexer* getMultiplexer(Logr::log_t log) return ret; } catch (FDMultiplexerException& fe) { - SLOG(g_log << Logger::Warning << "Non-fatal error initializing possible multiplexer (" << fe.what() << "), falling back" << endl, - log->error(Logr::Warning, fe.what(), "Non-fatal error initializing possible multiplexer, falling back")); + log->error(Logr::Warning, fe.what(), "Non-fatal error initializing possible multiplexer, falling back"); } catch (...) { - SLOG(g_log << Logger::Warning << "Non-fatal error initializing possible multiplexer" << endl, - log->info(Logr::Warning, "Non-fatal error initializing possible multiplexer")); + log->info(Logr::Warning, "Non-fatal error initializing possible multiplexer"); } } - SLOG(g_log << Logger::Error << "No working multiplexer found!" << endl, - log->info(Logr::Error, "No working multiplexer found!")); + log->info(Logr::Error, "No working multiplexer found!"); _exit(1); } @@ -468,12 +456,10 @@ static std::shared_ptr>> startProtobuf result->emplace_back(std::move(logger)); } catch (const std::exception& e) { - SLOG(g_log << Logger::Error << "Error while starting protobuf logger to '" << server << ": " << e.what() << endl, - log->error(Logr::Error, e.what(), "Exception while starting protobuf logger", "exception", Logging::Loggable("std::exception"), "server", Logging::Loggable(server))); + log->error(Logr::Error, e.what(), "Exception while starting protobuf logger", "exception", Logging::Loggable("std::exception"), "server", Logging::Loggable(server)); } catch (const PDNSException& e) { - SLOG(g_log << Logger::Error << "Error while starting protobuf logger to '" << server << ": " << e.reason << endl, - log->error(Logr::Error, e.reason, "Exception while starting protobuf logger", "exception", Logging::Loggable("PDNSException"), "server", Logging::Loggable(server))); + log->error(Logr::Error, e.reason, "Exception while starting protobuf logger", "exception", Logging::Loggable("PDNSException"), "server", Logging::Loggable(server)); } } @@ -703,12 +689,10 @@ static std::shared_ptr>> startFra result->emplace_back(std::move(fsl)); } catch (const std::exception& e) { - SLOG(g_log << Logger::Error << "Error while starting dnstap framestream logger to '" << server << ": " << e.what() << endl, - log->error(Logr::Error, e.what(), "Exception while starting dnstap framestream logger", "exception", Logging::Loggable("std::exception"), "server", Logging::Loggable(server))); + log->error(Logr::Error, e.what(), "Exception while starting dnstap framestream logger", "exception", Logging::Loggable("std::exception"), "server", Logging::Loggable(server)); } catch (const PDNSException& e) { - SLOG(g_log << Logger::Error << "Error while starting dnstap framestream logger to '" << server << ": " << e.reason << endl, - log->error(Logr::Error, e.reason, "Exception while starting dnstap framestream logger", "exception", Logging::Loggable("PDNSException"), "server", Logging::Loggable(server))); + log->error(Logr::Error, e.reason, "Exception while starting dnstap framestream logger", "exception", Logging::Loggable("PDNSException"), "server", Logging::Loggable(server)); } } @@ -800,8 +784,7 @@ static void writePid(Logr::log_t log) } else { int err = errno; - SLOG(g_log << Logger::Error << "Writing pid for " << Utility::getpid() << " to " << g_pidfname << " failed: " << stringerror(err) << endl, - log->error(Logr::Error, err, "Writing pid failed", "pid", Logging::Loggable(Utility::getpid()), "file", Logging::Loggable(g_pidfname))); + log->error(Logr::Error, err, "Writing pid failed", "pid", Logging::Loggable(Utility::getpid()), "file", Logging::Loggable(g_pidfname)); } } @@ -824,8 +807,7 @@ static void checkSocketDir(Logr::log_t log) return; } dir = ::arg()["chroot"] + dir; - SLOG(g_log << Logger::Error << "Problem with socket directory " << dir << ": " << msg << "; see https://docs.powerdns.com/recursor/upgrade.html#x-to-4-3-0" << endl, - log->error(Logr::Error, msg, "Problem with socket directory, see https://docs.powerdns.com/recursor/upgrade.html#x-to-4-3-0", "dir", Logging::Loggable(dir))); + log->error(Logr::Error, msg, "Problem with socket directory, see https://docs.powerdns.com/recursor/upgrade.html#x-to-4-3-0", "dir", Logging::Loggable(dir)); _exit(1); } @@ -839,13 +821,11 @@ static void setupNODThread(Logr::log_t log) g_nodDBp->setCacheDir(::arg()["new-domain-history-dir"]); } catch (const PDNSException& e) { - SLOG(g_log << Logger::Error << "new-domain-history-dir (" << ::arg()["new-domain-history-dir"] << ") is not readable or does not exist" << endl, - log->error(Logr::Error, e.reason, "new-domain-history-dir is not readable or does not exists", "dir", Logging::Loggable(::arg()["new-domain-history-dir"]))); + log->error(Logr::Error, e.reason, "new-domain-history-dir is not readable or does not exists", "dir", Logging::Loggable(::arg()["new-domain-history-dir"])); _exit(1); } if (!g_nodDBp->init()) { - SLOG(g_log << Logger::Error << "Could not initialize domain tracking" << endl, - log->info(Logr::Error, "Could not initialize domain tracking")); + log->info(Logr::Error, "Could not initialize domain tracking"); _exit(1); } if (::arg().asNum("new-domain-db-snapshot-interval") > 0) { @@ -863,13 +843,11 @@ static void setupNODThread(Logr::log_t log) g_udrDBp->setCacheDir(::arg()["unique-response-history-dir"]); } catch (const PDNSException& e) { - SLOG(g_log << Logger::Error << "unique-response-history-dir (" << ::arg()["unique-response-history-dir"] << ") is not readable or does not exist" << endl, - log->info(Logr::Error, "unique-response-history-dir is not readable or does not exist", "dir", Logging::Loggable(::arg()["unique-response-history-dir"]))); + log->info(Logr::Error, "unique-response-history-dir is not readable or does not exist", "dir", Logging::Loggable(::arg()["unique-response-history-dir"])); _exit(1); } if (!g_udrDBp->init()) { - SLOG(g_log << Logger::Error << "Could not initialize unique response tracking" << endl, - log->info(Logr::Error, "Could not initialize unique response tracking")); + log->info(Logr::Error, "Could not initialize unique response tracking"); _exit(1); } if (::arg().asNum("new-domain-db-snapshot-interval") > 0) { @@ -906,8 +884,7 @@ static void parseIgnorelistFile(const std::string& fname, SuffixMatchNode& match matchNode.add(DNSName(line)); } catch (const std::exception& e) { - SLOG(g_log << Logger::Warning << "Ignoring line of ignorelist due to an error: " << e.what() << endl, - g_slog->withName("config")->error(Logr::Warning, e.what(), "Ignoring line of ignorelist due to an error", "exception", Logging::Loggable("std::exception"))); + g_slog->withName("config")->error(Logr::Warning, e.what(), "Ignoring line of ignorelist due to an error", "exception", Logging::Loggable("std::exception")); } } } @@ -941,8 +918,7 @@ static void daemonize(Logr::log_t log) if (auto pid = fork(); pid != 0) { if (pid < 0) { int err = errno; - SLOG(g_log << Logger::Critical << "Fork failed: " << stringerror(err) << endl, - log->error(Logr::Critical, err, "Fork failed")); + log->error(Logr::Critical, err, "Fork failed"); exit(1); // NOLINT(concurrency-mt-unsafe) } exit(0); // NOLINT(concurrency-mt-unsafe) @@ -953,8 +929,7 @@ static void daemonize(Logr::log_t log) int devNull = open("/dev/null", O_RDWR); /* open stdin */ if (devNull < 0) { int err = errno; - SLOG(g_log << Logger::Critical << "Unable to open /dev/null: " << stringerror(err) << endl, - log->error(Logr::Critical, err, "Unable to open /dev/null")); + log->error(Logr::Critical, err, "Unable to open /dev/null"); } else { dup2(devNull, 0); /* stdin */ @@ -988,8 +963,7 @@ static void checkLinuxIPv6Limits([[maybe_unused]] Logr::log_t log) if (readFileIfThere("/proc/sys/net/ipv6/route/max_size", &line)) { int lim = std::stoi(line); if (lim < 16384) { - SLOG(g_log << Logger::Error << "If using IPv6, please raise sysctl net.ipv6.route.max_size, currently set to " << lim << " which is < 16384" << endl, - log->info(Logr::Error, "If using IPv6, please raise sysctl net.ipv6.route.max_size to a size >= 16384", "current", Logging::Loggable(lim))); + log->info(Logr::Error, "If using IPv6, please raise sysctl net.ipv6.route.max_size to a size >= 16384", "current", Logging::Loggable(lim)); } } #endif @@ -1007,10 +981,9 @@ static void checkOrFixLinuxMapCountLimits([[maybe_unused]] Logr::log_t log) auto mapsNeeded = 4ULL * g_maxMThreads * workers; if (lim < mapsNeeded) { g_maxMThreads = static_cast(lim / (4ULL * workers)); - SLOG(g_log << Logger::Error << "sysctl vm.max_map_count= <" << mapsNeeded << ", this may cause 'bad_alloc' exceptions; adjusting max-mthreads to " << g_maxMThreads << endl, - log->info(Logr::Error, "sysctl vm.max_map_count < mapsNeeded, this may cause 'bad_alloc' exceptions, adjusting max-mthreads", - "vm.max_map_count", Logging::Loggable(lim), "mapsNeeded", Logging::Loggable(mapsNeeded), - "max-mthreads", Logging::Loggable(g_maxMThreads))); + log->info(Logr::Error, "sysctl vm.max_map_count < mapsNeeded, this may cause 'bad_alloc' exceptions, adjusting max-mthreads", + "vm.max_map_count", Logging::Loggable(lim), "mapsNeeded", Logging::Loggable(mapsNeeded), + "max-mthreads", Logging::Loggable(g_maxMThreads)); } } #endif @@ -1347,9 +1320,8 @@ static std::shared_ptr parseACL(const std::string& aclFile, const result->addMask(line); } } - SLOG(g_log << Logger::Info << "Done parsing " << result->size() << " " << aclSetting << " ranges from file '" << file << "' - overriding '" << aclSetting << "' setting" << endl, - log->info(Logr::Info, "Done parsing ranges from file, will override setting", "setting", Logging::Loggable(aclSetting), - "number", Logging::Loggable(result->size()), "file", Logging::Loggable(file))); + log->info(Logr::Info, "Done parsing ranges from file, will override setting", "setting", Logging::Loggable(aclSetting), + "number", Logging::Loggable(result->size()), "file", Logging::Loggable(file)); } else if (!::arg()[aclSetting].empty()) { vector ips; @@ -1482,8 +1454,7 @@ void parseACLs() if (allowFrom->empty()) { if (::arg()["local-address"] != "127.0.0.1" && ::arg().asNum("local-port") == 53) { - SLOG(g_log << Logger::Warning << "WARNING: Allowing queries from all IP addresses - this can be a security risk!" << endl, - log->info(Logr::Warning, "WARNING: Allowing queries from all IP addresses - this can be a security risk!")); + log->info(Logr::Warning, "WARNING: Allowing queries from all IP addresses - this can be a security risk!"); } allowFrom = nullptr; } @@ -1669,34 +1640,28 @@ static int initNet(Logr::log_t log) pdns::parseQueryLocalAddress(::arg()["query-local-address"]); } catch (std::exception& e) { - SLOG(g_log << Logger::Error << "Assigning local query addresses: " << e.what(), - log->error(Logr::Error, e.what(), "Unable to assign local query address")); + log->error(Logr::Error, e.what(), "Unable to assign local query address"); return 99; } if (pdns::isQueryLocalAddressFamilyEnabled(AF_INET)) { SyncRes::s_doIPv4 = true; - SLOG(g_log << Logger::Warning << "Enabling IPv4 transport for outgoing queries" << endl, - log->info(Logr::Notice, "Enabling IPv4 transport for outgoing queries")); + log->info(Logr::Notice, "Enabling IPv4 transport for outgoing queries"); } else { - SLOG(g_log << Logger::Warning << "NOT using IPv4 for outgoing queries - add an IPv4 address (like '0.0.0.0') to query-local-address to enable" << endl, - log->info(Logr::Warning, "NOT using IPv4 for outgoing queries - add an IPv4 address (like '0.0.0.0') to query-local-address to enable")); + log->info(Logr::Warning, "NOT using IPv4 for outgoing queries - add an IPv4 address (like '0.0.0.0') to query-local-address to enable"); } if (pdns::isQueryLocalAddressFamilyEnabled(AF_INET6)) { SyncRes::s_doIPv6 = true; - SLOG(g_log << Logger::Warning << "Enabling IPv6 transport for outgoing queries" << endl, - log->info(Logr::Notice, "Enabling IPv6 transport for outgoing queries")); + log->info(Logr::Notice, "Enabling IPv6 transport for outgoing queries"); } else { - SLOG(g_log << Logger::Warning << "NOT using IPv6 for outgoing queries - add an IPv6 address (like '::') to query-local-address to enable" << endl, - log->info(Logr::Warning, "NOT using IPv6 for outgoing queries - add an IPv6 address (like '::') to query-local-address to enable")); + log->info(Logr::Warning, "NOT using IPv6 for outgoing queries - add an IPv6 address (like '::') to query-local-address to enable"); } if (!SyncRes::s_doIPv6 && !SyncRes::s_doIPv4) { - SLOG(g_log << Logger::Error << "No outgoing addresses configured! Can not continue" << endl, - log->info(Logr::Error, "No outgoing addresses configured! Can not continue")); + log->info(Logr::Error, "No outgoing addresses configured! Can not continue"); return 99; } return 0; @@ -1720,8 +1685,7 @@ static int initDNSSEC(Logr::log_t log) g_dnssecmode = DNSSECMode::ValidateForLog; } else { - SLOG(g_log << Logger::Error << "Unknown DNSSEC mode " << ::arg()["dnssec"] << endl, - log->info(Logr::Error, "Unknown DNSSEC mode", "dnssec", Logging::Loggable(::arg()["dnssec"]))); + log->info(Logr::Error, "Unknown DNSSEC mode", "dnssec", Logging::Loggable(::arg()["dnssec"])); return 1; } @@ -1846,8 +1810,7 @@ static int initSyncRes(Logr::log_t log) { uint64_t sse = ::arg().asNum("serve-stale-extensions"); if (sse > std::numeric_limits::max()) { - SLOG(g_log << Logger::Error << "Illegal serve-stale-extensions value: " << sse << "; range = 0..65536" << endl, - log->info(Logr::Error, "Illegal serve-stale-extensions value; range = 0..65536", "value", Logging::Loggable(sse))); + log->info(Logr::Error, "Illegal serve-stale-extensions value; range = 0..65536", "value", Logging::Loggable(sse)); return 1; } MemRecursorCache::s_maxServedStaleExtensions = sse; @@ -1882,8 +1845,7 @@ static int initSyncRes(Logr::log_t log) SyncRes::s_hardenNXD = SyncRes::HardenNXD::No; } else if (value != "dnssec") { - SLOG(g_log << Logger::Error << "Unknown nothing-below-nxdomain mode: " << value << endl, - log->info(Logr::Error, "Unknown nothing-below-nxdomain mode", "mode", Logging::Loggable(value))); + log->info(Logr::Error, "Unknown nothing-below-nxdomain mode", "mode", Logging::Loggable(value)); return 1; } @@ -1926,8 +1888,7 @@ static unsigned int initDistribution(Logr::log_t log) g_balancingFactor = ::arg().asDouble("distribution-load-factor"); if (g_balancingFactor != 0.0 && g_balancingFactor < 1.0) { g_balancingFactor = 0.0; - SLOG(g_log << Logger::Warning << "Asked to run with a distribution-load-factor below 1.0, disabling it instead" << endl, - log->info(Logr::Warning, "Asked to run with a distribution-load-factor below 1.0, disabling it instead")); + log->info(Logr::Warning, "Asked to run with a distribution-load-factor below 1.0, disabling it instead"); } #ifdef SO_REUSEPORT @@ -1989,8 +1950,7 @@ static int initForks(Logr::log_t log) } if (::arg().mustDo("daemon")) { - SLOG(g_log << Logger::Warning << "Calling daemonize, going to background" << endl, - log->info(Logr::Warning, "Calling daemonize, going to background")); + log->info(Logr::Warning, "Calling daemonize, going to background"); g_log.toConsole(Logger::Critical); daemonize(log); } @@ -2023,15 +1983,13 @@ static int initPorts(Logr::log_t log) { int port = ::arg().asNum("udp-source-port-min"); if (port < 1024 || port > 65535) { - SLOG(g_log << Logger::Error << "Unable to launch, udp-source-port-min is not a valid port number" << endl, - log->info(Logr::Error, "Unable to launch, udp-source-port-min is not a valid port number")); + log->info(Logr::Error, "Unable to launch, udp-source-port-min is not a valid port number"); return 99; // this isn't going to fix itself either } g_minUdpSourcePort = port; port = ::arg().asNum("udp-source-port-max"); if (port < 1024 || port > 65535 || port < g_minUdpSourcePort) { - SLOG(g_log << Logger::Error << "Unable to launch, udp-source-port-max is not a valid port number or is smaller than udp-source-port-min" << endl, - log->info(Logr::Error, "Unable to launch, udp-source-port-max is not a valid port number or is smaller than udp-source-port-min")); + log->info(Logr::Error, "Unable to launch, udp-source-port-max is not a valid port number or is smaller than udp-source-port-min"); return 99; // this isn't going to fix itself either } g_maxUdpSourcePort = port; @@ -2040,8 +1998,7 @@ static int initPorts(Logr::log_t log) for (const auto& part : parts) { port = std::stoi(part); if (port < 1024 || port > 65535) { - SLOG(g_log << Logger::Error << "Unable to launch, udp-source-port-avoid contains an invalid port number: " << part << endl, - log->info(Logr::Error, "Unable to launch, udp-source-port-avoid contains an invalid port number", "port", Logging::Loggable(part))); + log->info(Logr::Error, "Unable to launch, udp-source-port-avoid contains an invalid port number", "port", Logging::Loggable(part)); return 99; // this isn't going to fix itself either } g_avoidUdpSourcePorts.insert(port); @@ -2061,8 +2018,7 @@ static void initSNMP([[maybe_unused]] Logr::log_t log) g_snmpAgent->run(); #else const std::string msg = "snmp-agent set but SNMP support not compiled in"; - SLOG(g_log << Logger::Error << msg << endl, - log->info(Logr::Error, msg)); + log->info(Logr::Error, msg); #endif // HAVE_NET_SNMP } } @@ -2074,19 +2030,16 @@ static int initControl(Logr::log_t log, uid_t newuid, int forks) char* ns; ns = getenv("NOTIFY_SOCKET"); if (ns != nullptr) { - SLOG(g_log << Logger::Error << "Unable to chroot when running from systemd. Please disable chroot= or set the 'Type' for this service to 'simple'" << endl, - log->info(Logr::Error, "Unable to chroot when running from systemd. Please disable chroot= or set the 'Type' for this service to 'simple'")); + log->info(Logr::Error, "Unable to chroot when running from systemd. Please disable chroot= or set the 'Type' for this service to 'simple'"); return 1; } #endif if (chroot(::arg()["chroot"].c_str()) < 0 || chdir("/") < 0) { int err = errno; - SLOG(g_log << Logger::Error << "Unable to chroot to '" + ::arg()["chroot"] + "': " << stringerror(err) << ", exiting" << endl, - log->error(Logr::Error, err, "Unable to chroot", "chroot", Logging::Loggable(::arg()["chroot"]))); + log->error(Logr::Error, err, "Unable to chroot", "chroot", Logging::Loggable(::arg()["chroot"])); return 1; } - SLOG(g_log << Logger::Info << "Chrooted to '" << ::arg()["chroot"] << "'" << endl, - log->info(Logr::Info, "Chrooted", "chroot", Logging::Loggable(::arg()["chroot"]))); + log->info(Logr::Info, "Chrooted", "chroot", Logging::Loggable(::arg()["chroot"])); } checkSocketDir(log); @@ -2108,8 +2061,7 @@ static int initControl(Logr::log_t log, uid_t newuid, int forks) dropCapabilities(); } catch (const std::exception& e) { - SLOG(g_log << Logger::Warning << e.what() << endl, - log->error(Logr::Warning, e.what(), "Could not drop capabilities")); + log->error(Logr::Warning, e.what(), "Could not drop capabilities"); } return 0; } @@ -2146,8 +2098,7 @@ static void initSuffixMatchNodes([[maybe_unused]] Logr::log_t log) stringtok(parts, ::arg()["dot-to-auth-names"], " ,"); #ifndef HAVE_DNS_OVER_TLS if (!parts.empty()) { - SLOG(g_log << Logger::Error << "dot-to-auth-names setting contains names, but Recursor was built without DNS over TLS support. Setting will be ignored." << endl, - log->info(Logr::Error, "dot-to-auth-names setting contains names, but Recursor was built without DNS over TLS support. Setting will be ignored")); + log->info(Logr::Error, "dot-to-auth-names setting contains names, but Recursor was built without DNS over TLS support. Setting will be ignored"); } #endif for (const auto& part : parts) { @@ -2173,8 +2124,7 @@ static int initDNS64(Logr::log_t log) try { auto dns64Prefix = Netmask(::arg()["dns64-prefix"]); if (dns64Prefix.getBits() != 96) { - SLOG(g_log << Logger::Error << "Invalid prefix for 'dns64-prefix', the current implementation only supports /96 prefixes: " << ::arg()["dns64-prefix"] << endl, - log->info(Logr::Error, "Invalid prefix for 'dns64-prefix', the current implementation only supports /96 prefixes", "prefix", Logging::Loggable(::arg()["dns64-prefix"]))); + log->info(Logr::Error, "Invalid prefix for 'dns64-prefix', the current implementation only supports /96 prefixes", "prefix", Logging::Loggable(::arg()["dns64-prefix"])); return 1; } g_dns64Prefix = dns64Prefix.getNetwork(); @@ -2185,8 +2135,7 @@ static int initDNS64(Logr::log_t log) } } catch (const NetmaskException& ne) { - SLOG(g_log << Logger::Error << "Invalid prefix '" << ::arg()["dns64-prefix"] << "' for 'dns64-prefix': " << ne.reason << endl, - log->info(Logr::Error, "Invalid prefix", "dns64-prefix", Logging::Loggable(::arg()["dns64-prefix"]))); + log->info(Logr::Error, "Invalid prefix", "dns64-prefix", Logging::Loggable(::arg()["dns64-prefix"])); return 1; } } @@ -2206,8 +2155,7 @@ static int serviceMain(Logr::log_t log) g_log.setFacility(val); } else { - SLOG(g_log << Logger::Error << "Unknown logging facility " << ::arg().asNum("logging-facility") << endl, - log->info(Logr::Error, "Unknown logging facility", "facility", Logging::Loggable(::arg().asNum("logging-facility")))); + log->info(Logr::Error, "Unknown logging facility", "facility", Logging::Loggable(::arg().asNum("logging-facility"))); } } @@ -2226,8 +2174,7 @@ static int serviceMain(Logr::log_t log) auto luaResult = luaconfig(false); if (luaResult.d_ret != 0) { - SLOG(g_log << Logger::Error << "Cannot load Lua or equivalent YAML configuration: " << luaResult.d_str << endl, - log->error(Logr::Error, luaResult.d_str, "Cannot load Lua or equivalent YAML configuration")); + log->error(Logr::Error, luaResult.d_str, "Cannot load Lua or equivalent YAML configuration"); return 1; } @@ -2238,8 +2185,7 @@ static int serviceMain(Logr::log_t log) RecThreadInfo::setWeDistributeQueries(::arg().mustDo("pdns-distributes-queries")); if (RecThreadInfo::weDistributeQueries()) { - SLOG(g_log << Logger::Warning << "PowerDNS Recursor itself will distribute queries over threads" << endl, - log->info(Logr::Notice, "PowerDNS Recursor itself will distribute queries over threads")); + log->info(Logr::Notice, "PowerDNS Recursor itself will distribute queries over threads"); } g_outgoingEDNSBufsize = ::arg().asNum("edns-outgoing-bufsize"); @@ -2304,8 +2250,7 @@ static int serviceMain(Logr::log_t log) g_paddingMode = PaddingMode::PaddedQueries; } else { - SLOG(g_log << Logger::Error << "Unknown edns-padding-mode: " << ::arg()["edns-padding-mode"] << endl, - log->info(Logr::Error, "Unknown edns-padding-mode", "edns-padding-mode", Logging::Loggable(::arg()["edns-padding-mode"]))); + log->info(Logr::Error, "Unknown edns-padding-mode", "edns-padding-mode", Logging::Loggable(::arg()["edns-padding-mode"])); return 1; } g_paddingTag = ::arg().asNum("edns-padding-tag"); @@ -2315,14 +2260,12 @@ static int serviceMain(Logr::log_t log) RecThreadInfo::setNumDistributorThreads(::arg().asNum("distributor-threads")); RecThreadInfo::setNumUDPWorkerThreads(::arg().asNum("threads")); if (RecThreadInfo::numUDPWorkers() < 1) { - SLOG(g_log << Logger::Warning << "Asked to run with 0 threads, raising to 1 instead" << endl, - log->info(Logr::Warning, "Asked to run with 0 threads, raising to 1 instead")); + log->info(Logr::Warning, "Asked to run with 0 threads, raising to 1 instead"); RecThreadInfo::setNumUDPWorkerThreads(1); } RecThreadInfo::setNumTCPWorkerThreads(::arg().asNum("tcp-threads")); if (RecThreadInfo::numTCPWorkers() < 1) { - SLOG(g_log << Logger::Warning << "Asked to run with 0 TCP threads, raising to 1 instead" << endl, - log->info(Logr::Warning, "Asked to run with 0 TCP threads, raising to 1 instead")); + log->info(Logr::Warning, "Asked to run with 0 TCP threads, raising to 1 instead"); RecThreadInfo::setNumTCPWorkerThreads(1); } @@ -2330,8 +2273,7 @@ static int serviceMain(Logr::log_t log) int64_t maxInFlight = ::arg().asNum("max-concurrent-requests-per-tcp-connection"); if (maxInFlight < 1 || maxInFlight > USHRT_MAX || maxInFlight >= g_maxMThreads) { - SLOG(g_log << Logger::Warning << "Asked to run with illegal max-concurrent-requests-per-tcp-connection, setting to default (10)" << endl, - log->info(Logr::Warning, "Asked to run with illegal max-concurrent-requests-per-tcp-connection, setting to default (10)")); + log->info(Logr::Warning, "Asked to run with illegal max-concurrent-requests-per-tcp-connection, setting to default (10)"); TCPConnection::s_maxInFlight = 10; } else { @@ -2355,15 +2297,13 @@ static int serviceMain(Logr::log_t log) g_aggressiveNSECCache = make_unique(::arg().asNum("aggressive-nsec-cache-size")); } else { - SLOG(g_log << Logger::Warning << "Aggressive NSEC/NSEC3 caching is enabled but DNSSEC validation is not set to 'validate', 'log-fail' or 'process', ignoring" << endl, - log->info(Logr::Warning, "Aggressive NSEC/NSEC3 caching is enabled but DNSSEC validation is not set to 'validate', 'log-fail' or 'process', ignoring")); + log->info(Logr::Warning, "Aggressive NSEC/NSEC3 caching is enabled but DNSSEC validation is not set to 'validate', 'log-fail' or 'process', ignoring"); } } AggressiveNSECCache::s_nsec3DenialProofMaxCost = ::arg().asNum("aggressive-cache-max-nsec3-hash-cost"); AggressiveNSECCache::s_maxNSEC3CommonPrefix = static_cast(std::round(std::log2(::arg().asNum("aggressive-cache-min-nsec3-hit-ratio")))); - SLOG(g_log << Logger::Debug << "NSEC3 aggressive cache tuning: aggressive-cache-min-nsec3-hit-ratio: " << ::arg().asNum("aggressive-cache-min-nsec3-hit-ratio") << " max common prefix bits: " << std::to_string(AggressiveNSECCache::s_maxNSEC3CommonPrefix) << endl, - log->info(Logr::Debug, "NSEC3 aggressive cache tuning", "aggressive-cache-min-nsec3-hit-ratio", Logging::Loggable(::arg().asNum("aggressive-cache-min-nsec3-hit-ratio")), "maxCommonPrefixBits", Logging::Loggable(AggressiveNSECCache::s_maxNSEC3CommonPrefix))); + log->info(Logr::Debug, "NSEC3 aggressive cache tuning", "aggressive-cache-min-nsec3-hit-ratio", Logging::Loggable(::arg().asNum("aggressive-cache-min-nsec3-hit-ratio")), "maxCommonPrefixBits", Logging::Loggable(AggressiveNSECCache::s_maxNSEC3CommonPrefix)); initSuffixMatchNodes(log); initCarbon(); @@ -2390,8 +2330,7 @@ static int serviceMain(Logr::log_t log) #ifdef HAVE_LIBSODIUM if (sodium_init() == -1) { - SLOG(g_log << Logger::Error << "Unable to initialize sodium crypto library" << endl, - log->info(Logr::Error, "Unable to initialize sodium crypto library")); + log->info(Logr::Error, "Unable to initialize sodium crypto library"); return 99; } #endif @@ -2497,8 +2436,7 @@ static void handleRCC(int fileDesc, FDMultiplexer::funcparam_t& /* var */) throw PDNSException("accept failed"); } string msg = g_rcc.recv(clientfd).d_str; - SLOG(g_log << Logger::Info << "Received rec_control command '" << msg << "' via controlsocket" << endl, - log->info(Logr::Info, "Received rec_control command via control socket", "command", Logging::Loggable(msg))); + log->info(Logr::Info, "Received rec_control command via control socket", "command", Logging::Loggable(msg)); RecursorControlParser::func_t* command = nullptr; auto answer = RecursorControlParser::getAnswer(clientfd, msg, &command); @@ -2512,12 +2450,10 @@ static void handleRCC(int fileDesc, FDMultiplexer::funcparam_t& /* var */) } } catch (const std::exception& e) { - 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 socket request", "exception", Logging::Loggable("std::exception"))); + log->error(Logr::Error, e.what(), "Exception while dealing with control socket request", "exception", Logging::Loggable("std::exception")); } catch (const PDNSException& ae) { - 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 socket request", "exception", Logging::Loggable("PDNSException"))); + log->error(Logr::Error, ae.reason, "Exception while dealing with control socket request", "exception", Logging::Loggable("PDNSException")); } } @@ -2699,24 +2635,19 @@ static void houseKeepingWork(Logr::log_t log) doSecPoll(&t_last_secpoll, log); } catch (const std::exception& e) { - SLOG(g_log << Logger::Error << "Exception while performing security poll: " << e.what() << endl, - log->error(Logr::Error, e.what(), "Exception while performing security poll")); + log->error(Logr::Error, e.what(), "Exception while performing security poll"); } catch (const PDNSException& e) { - SLOG(g_log << Logger::Error << "Exception while performing security poll: " << e.reason << endl, - log->error(Logr::Error, e.reason, "Exception while performing security poll")); + log->error(Logr::Error, e.reason, "Exception while performing security poll"); } catch (const ImmediateServFailException& e) { - SLOG(g_log << Logger::Error << "Exception while performing security poll: " << e.reason << endl, - log->error(Logr::Error, e.reason, "Exception while performing security poll")); + log->error(Logr::Error, e.reason, "Exception while performing security poll"); } catch (const PolicyHitException& e) { - SLOG(g_log << Logger::Error << "Policy hit while performing security poll" << endl, - log->info(Logr::Error, "Policy hit while performing security poll")); + log->info(Logr::Error, "Policy hit while performing security poll"); } catch (...) { - SLOG(g_log << Logger::Error << "Exception while performing security poll" << endl, - log->info(Logr::Error, "Exception while performing security poll")); + log->info(Logr::Error, "Exception while performing security poll"); } }); @@ -2730,8 +2661,7 @@ static void houseKeepingWork(Logr::log_t log) trustAnchorTask.setPeriod(taInterval); trustAnchorTask.runIfDue(now, [&luaconfsLocal, &log]() { if (!luaconfsLocal->trustAnchorFileInfo.fname.empty() && luaconfsLocal->trustAnchorFileInfo.interval != 0) { - SLOG(g_log << Logger::Debug << "Refreshing Trust Anchors from file" << endl, - log->info(Logr::Debug, "Refreshing Trust Anchors from file")); + log->info(Logr::Debug, "Refreshing Trust Anchors from file"); try { map dsAnchors; if (updateTrustAnchorsFromFile(luaconfsLocal->trustAnchorFileInfo.fname, dsAnchors, log)) { @@ -2741,8 +2671,7 @@ static void houseKeepingWork(Logr::log_t log) } } catch (const PDNSException& pe) { - SLOG(g_log << Logger::Error << "Unable to update Trust Anchors: " << pe.reason << endl, - log->error(Logr::Error, pe.reason, "Unable to update Trust Anchors")); + log->error(Logr::Error, pe.reason, "Unable to update Trust Anchors"); } } }); @@ -2765,14 +2694,12 @@ static void houseKeeping(void* /* ignored */) } catch (const PDNSException& ae) { t_running = false; - SLOG(g_log << Logger::Error << "Fatal error in housekeeping thread: " << ae.reason << endl, - log->error(Logr::Error, ae.reason, "Fatal error in housekeeping thread")); + log->error(Logr::Error, ae.reason, "Fatal error in housekeeping thread"); throw; } catch (...) { t_running = false; - SLOG(g_log << Logger::Error << "Uncaught exception in housekeeping thread" << endl, - log->info(Logr::Error, "Uncaught exception in housekeeping thread")); + log->info(Logr::Error, "Uncaught exception in housekeeping thread"); throw; } } @@ -2833,8 +2760,7 @@ static void recLoop() for (const auto& exp : expired) { auto conn = boost::any_cast>(exp.second); if (g_logCommonErrors) { - SLOG(g_log << Logger::Warning << "Timeout from remote TCP client " << conn->d_remote.toStringWithPort() << endl, - g_slogtcpin->info(Logr::Warning, "Timeout from remote TCP client", "remote", Logging::Loggable(conn->d_remote))); + g_slogtcpin->info(Logr::Warning, "Timeout from remote TCP client", "remote", Logging::Loggable(conn->d_remote)); } t_fdm->removeReadFD(exp.first); } @@ -2899,11 +2825,9 @@ static void recursorThread() if (!primeHints()) { threadInfo.setExitCode(EXIT_FAILURE); RecursorControlChannel::stop = true; - SLOG(g_log << Logger::Critical << "Priming cache failed, stopping" << endl, - log->info(Logr::Critical, "Priming cache failed, stopping")); + log->info(Logr::Critical, "Priming cache failed, stopping"); } - SLOG(g_log << Logger::Debug << "Done priming cache with root hints" << endl, - log->info(Logr::Debug, "Done priming cache with root hints")); + log->info(Logr::Debug, "Done priming cache with root hints"); } } @@ -2913,13 +2837,11 @@ static void recursorThread() if (!::arg()["lua-dns-script"].empty()) { t_pdl = std::make_shared(); t_pdl->loadFile(::arg()["lua-dns-script"]); - SLOG(g_log << Logger::Warning << "Loaded 'lua' script from '" << ::arg()["lua-dns-script"] << "'" << endl, - log->info(Logr::Warning, "Loading Lua script from file", "name", Logging::Loggable(::arg()["lua-dns-script"]))); + log->info(Logr::Warning, "Loading Lua script from file", "name", Logging::Loggable(::arg()["lua-dns-script"])); } } catch (std::exception& e) { - SLOG(g_log << Logger::Error << "Failed to load 'lua' script from '" << ::arg()["lua-dns-script"] << "': " << e.what() << endl, - log->error(Logr::Error, e.what(), "Failed to load Lua script from file", "name", Logging::Loggable(::arg()["lua-dns-script"]))); + log->error(Logr::Error, e.what(), "Failed to load Lua script from file", "name", Logging::Loggable(::arg()["lua-dns-script"])); _exit(99); } } @@ -2970,8 +2892,7 @@ static void recursorThread() t_fdm->addReadFD(threadInfo.getPipes().readToThread, handlePipeRequest); if (threadInfo.isHandler()) { - SLOG(g_log << Logger::Info << "Enabled '" << t_fdm->getName() << "' multiplexer" << endl, - log->info(Logr::Info, "Enabled multiplexer", "name", Logging::Loggable(t_fdm->getName()))); + log->info(Logr::Info, "Enabled multiplexer", "name", Logging::Loggable(t_fdm->getName())); } else { t_fdm->addReadFD(threadInfo.getPipes().readQueriesToThread, handlePipeRequest); @@ -3008,16 +2929,13 @@ static void recursorThread() recLoop(); } catch (const PDNSException& ae) { - SLOG(g_log << Logger::Error << "Exception: " << ae.reason << endl, - log->error(Logr::Error, ae.reason, "Exception in RecursorThread", "exception", Logging::Loggable("PDNSException"))); + log->error(Logr::Error, ae.reason, "Exception in RecursorThread", "exception", Logging::Loggable("PDNSException")); } catch (const std::exception& e) { - SLOG(g_log << Logger::Error << "STL Exception: " << e.what() << endl, - log->error(Logr::Error, e.what(), "Exception in RecursorThread", "exception", Logging::Loggable("std::exception"))); + log->error(Logr::Error, e.what(), "Exception in RecursorThread", "exception", Logging::Loggable("std::exception")); } catch (...) { - SLOG(g_log << Logger::Error << "any other exception in main: " << endl, - log->info(Logr::Error, "Exception in RecursorThread")); + log->info(Logr::Error, "Exception in RecursorThread"); } } @@ -3052,16 +2970,14 @@ static pair doConfig(Logr::log_t startupLog, const string& configname if (config == "check") { try { if (!::arg().file(configname)) { - SLOG(g_log << Logger::Warning << "Unable to open configuration file '" << configname << "'" << endl, - startupLog->error("No such file", "Unable to open configuration file", "config_file", Logging::Loggable(configname))); + startupLog->error("No such file", "Unable to open configuration file", "config_file", Logging::Loggable(configname)); return {1, true}; } ::arg().parse(argc, argv); return {0, true}; } catch (const ArgException& argException) { - SLOG(g_log << Logger::Warning << "Unable to parse configuration file '" << configname << "': " << argException.reason << endl, - startupLog->error("Cannot parse configuration", "Unable to parse configuration file", "config_file", Logging::Loggable(configname), "reason", Logging::Loggable(argException.reason))); + startupLog->error("Cannot parse configuration", "Unable to parse configuration file", "config_file", Logging::Loggable(configname), "reason", Logging::Loggable(argException.reason)); return {1, true}; } } @@ -3071,8 +2987,7 @@ static pair doConfig(Logr::log_t startupLog, const string& configname } else if (config == "diff") { if (!::arg().laxFile(configname)) { - SLOG(g_log << Logger::Warning << "Unable to open configuration file '" << configname << "'" << endl, - startupLog->error("No such file", "Unable to open configuration file", "config_file", Logging::Loggable(configname))); + startupLog->error("No such file", "Unable to open configuration file", "config_file", Logging::Loggable(configname)); return {1, true}; } ::arg().laxParse(argc, argv); @@ -3080,8 +2995,7 @@ static pair doConfig(Logr::log_t startupLog, const string& configname } else { if (!::arg().laxFile(configname)) { - SLOG(g_log << Logger::Warning << "Unable to open configuration file '" << configname << "'" << endl, - startupLog->error("No such file", "Unable to open configuration file", "config_file", Logging::Loggable(configname))); + startupLog->error("No such file", "Unable to open configuration file", "config_file", Logging::Loggable(configname)); return {1, true}; } ::arg().laxParse(argc, argv); @@ -3122,8 +3036,7 @@ static void handleRuntimeDefaults(Logr::log_t log) if (::arg()["server-id"] == RUNTIME) { // i.e. not set explicitly auto myHostname = getHostname(); if (!myHostname.has_value()) { - SLOG(g_log << Logger::Warning << "Unable to get the hostname, NSID and id.server values will be empty" << endl, - log->info(Logr::Warning, "Unable to get the hostname, NSID and id.server values will be empty")); + log->info(Logr::Warning, "Unable to get the hostname, NSID and id.server values will be empty"); } ::arg().set("server-id") = myHostname.has_value() ? *myHostname : ""; } @@ -3146,21 +3059,18 @@ static void handleRuntimeDefaults(Logr::log_t log) if (::arg().asNum("threads") == 1) { if (::arg().mustDo("pdns-distributes-queries")) { - SLOG(g_log << Logger::Warning << "Only one thread, no need to distribute queries ourselves" << endl, - log->info(Logr::Warning, "Only one thread, no need to distribute queries ourselves")); + log->info(Logr::Warning, "Only one thread, no need to distribute queries ourselves"); ::arg().set("pdns-distributes-queries") = "no"; } } if (::arg().mustDo("pdns-distributes-queries") && ::arg().asNum("distributor-threads") == 0) { - SLOG(g_log << Logger::Warning << "Asked to run with pdns-distributes-queries set but no distributor threads, raising to 1" << endl, - log->info(Logr::Warning, "Asked to run with pdns-distributes-queries set but no distributor threads, raising to 1")); + log->info(Logr::Warning, "Asked to run with pdns-distributes-queries set but no distributor threads, raising to 1"); ::arg().set("distributor-threads") = "1"; } if (!::arg().mustDo("pdns-distributes-queries") && ::arg().asNum("distributor-threads") > 0) { - SLOG(g_log << Logger::Warning << "Not distributing queries, setting distributor threads to 0" << endl, - log->info(Logr::Warning, "Not distributing queries, setting distributor threads to 0")); + log->info(Logr::Warning, "Not distributing queries, setting distributor threads to 0"); ::arg().set("distributor-threads") = "0"; } } @@ -3309,8 +3219,7 @@ int main(int argc, char** argv) return ret; } if (!::arg().file(configname)) { - SLOG(g_log << Logger::Warning << "Unable to open configuration file '" << configname << "'" << endl, - startupLog->error("No such file", "Unable to open configuration file", "config_file", Logging::Loggable(configname))); + startupLog->error("No such file", "Unable to open configuration file", "config_file", Logging::Loggable(configname)); } else { if (!::arg().mustDo("enable-old-settings")) { @@ -3338,8 +3247,7 @@ int main(int argc, char** argv) g_log.toConsole(s_logUrgency); if (!::arg()["chroot"].empty() && !::arg()["api-config-dir"].empty()) { - SLOG(g_log << Logger::Error << "Using chroot and enabling the API is not possible" << endl, - startupLog->info(Logr::Error, "Cannot use chroot and enable the API at the same time")); + startupLog->info(Logr::Error, "Cannot use chroot and enable the API at the same time"); return EXIT_FAILURE; } @@ -3371,18 +3279,15 @@ int main(int argc, char** argv) RecThreadInfo::joinThread0(); } catch (const PDNSException& ae) { - SLOG(g_log << Logger::Error << "Exception: " << ae.reason << endl, - g_slog->withName("config")->error(Logr::Critical, ae.reason, "Fatal error", "exception", Logging::Loggable("PDNSException"))); + 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::Critical, e.what(), "Fatal error", "exception", Logging::Loggable("std::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")->info(Logr::Critical, "Fatal error")); + g_slog->withName("config")->info(Logr::Critical, "Fatal error"); ret = EXIT_FAILURE; } @@ -3396,8 +3301,7 @@ static RecursorControlChannel::Answer* doReloadLuaScript() try { if (fname.empty()) { t_pdl.reset(); - SLOG(g_log << Logger::Info << RecThreadInfo::id() << " Unloaded current lua script" << endl, - log->info(Logr::Info, "Unloaded current lua script")); + log->info(Logr::Info, "Unloaded current lua script"); return new RecursorControlChannel::Answer{0, string("unloaded\n")}; } @@ -3407,19 +3311,16 @@ static RecursorControlChannel::Answer* doReloadLuaScript() } catch (std::runtime_error& ex) { string msg = std::to_string(RecThreadInfo::thread_local_id()) + " Retaining current script, could not read '" + fname + "': " + ex.what(); - SLOG(g_log << Logger::Error << msg << endl, - log->error(Logr::Error, ex.what(), "Retaining current script, could not read new script")); + 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) { - SLOG(g_log << Logger::Error << RecThreadInfo::thread_local_id() << " Retaining current script, error from '" << fname << "': " << e.what() << endl, - log->error(Logr::Error, e.what(), "Retaining current script, error in new script")); + 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")}; } - SLOG(g_log << Logger::Warning << RecThreadInfo::id() << " (Re)loaded lua script from '" << fname << "'" << endl, - log->info(Logr::Warning, "(Re)loaded lua script")); + log->info(Logr::Warning, "(Re)loaded lua script"); return new RecursorControlChannel::Answer{0, string("(re)loaded '" + fname + "'\n")}; } @@ -3476,8 +3377,7 @@ struct WipeCacheResult wipeCaches(const DNSName& canon, bool subtree, uint16_t q } catch (const std::exception& e) { auto log = g_slog->withName("runtime"); - SLOG(g_log << Logger::Warning << ", failed: " << e.what() << endl, - log->error(Logr::Warning, e.what(), "Wipecache failed")); + log->error(Logr::Warning, e.what(), "Wipecache failed"); } return res; @@ -3496,13 +3396,11 @@ void startLuaConfigDelayedThreads(const LuaConfigItems& luaConfig, uint64_t gene theThread.detach(); } catch (const std::exception& e) { - SLOG(g_log << Logger::Error << "Problem starting RPZIXFRTracker thread: " << e.what() << endl, - g_slog->withName("rpz")->error(Logr::Error, e.what(), "Exception starting RPZIXFRTracker thread", "exception", Logging::Loggable("std::exception"))); + g_slog->withName("rpz")->error(Logr::Error, e.what(), "Exception starting RPZIXFRTracker thread", "exception", Logging::Loggable("std::exception")); exit(1); // NOLINT(concurrency-mt-unsafe) } catch (const PDNSException& e) { - SLOG(g_log << Logger::Error << "Problem starting RPZIXFRTracker thread: " << e.reason << endl, - g_slog->withName("rpz")->error(Logr::Error, e.reason, "Exception starting RPZIXFRTracker thread", "exception", Logging::Loggable("PDNSException"))); + g_slog->withName("rpz")->error(Logr::Error, e.reason, "Exception starting RPZIXFRTracker thread", "exception", Logging::Loggable("PDNSException")); exit(1); // NOLINT(concurrency-mt-unsafe) } } @@ -3517,13 +3415,11 @@ void startLuaConfigDelayedThreads(const LuaConfigItems& luaConfig, uint64_t gene theThread.detach(); } catch (const std::exception& e) { - SLOG(g_log << Logger::Error << "Problem starting ZoneIXFRTracker thread: " << e.what() << endl, - g_slog->withName("zone")->error(Logr::Error, e.what(), "Exception starting ZoneXFRTracker thread", "exception", Logging::Loggable("std::exception"))); + g_slog->withName("zone")->error(Logr::Error, e.what(), "Exception starting ZoneXFRTracker thread", "exception", Logging::Loggable("std::exception")); exit(1); // NOLINT(concurrency-mt-unsafe) } catch (const PDNSException& e) { - SLOG(g_log << Logger::Error << "Problem starting ZoneIXFRTracker thread: " << e.reason << endl, - g_slog->withName("zone")->error(Logr::Error, e.reason, "Exception starting ZoneXFRTracker thread", "exception", Logging::Loggable("PDNSException"))); + g_slog->withName("zone")->error(Logr::Error, e.reason, "Exception starting ZoneXFRTracker thread", "exception", Logging::Loggable("PDNSException")); exit(1); // NOLINT(concurrency-mt-unsafe) } } @@ -3543,15 +3439,12 @@ static bool activateRPZFile(const RPZTrackerParams& params, LuaConfigItems& lci, zone->setName(params.polName.empty() ? "rpzFile" : params.polName); try { - SLOG(g_log << Logger::Warning << "Loading RPZ from file '" << params.name << "'" << endl, - log->info(Logr::Info, "Loading RPZ from file")); + log->info(Logr::Info, "Loading RPZ from file"); loadRPZFromFile(params.zoneXFRParams.name, zone, params.defpol, params.defpolOverrideLocal, params.maxTTL); - SLOG(g_log << Logger::Warning << "Done loading RPZ from file '" << params.name << "'" << endl, - log->info(Logr::Info, "Done loading RPZ from file")); + log->info(Logr::Info, "Done loading RPZ from file"); } catch (const std::exception& e) { - SLOG(g_log << Logger::Error << "Unable to load RPZ zone from '" << params.name << "': " << e.what() << endl, - log->error(Logr::Error, e.what(), "Exception while loading RPZ zone from file")); + log->error(Logr::Error, e.what(), "Exception while loading RPZ zone from file"); zone->clear(); return false; } @@ -3563,8 +3456,7 @@ static void activateRPZPrimary(RPZTrackerParams& params, LuaConfigItems& lci, sh auto log = lci.d_slog->withValues("seedfile", Logging::Loggable(params.seedFileName), "zone", Logging::Loggable(params.zoneXFRParams.name)); if (!params.seedFileName.empty()) { - SLOG(g_log << Logger::Info << "Pre-loading RPZ zone " << params.name << " from seed file '" << params.seedFileName << "'" << endl, - log->info(Logr::Info, "Pre-loading RPZ zone from seed file")); + log->info(Logr::Info, "Pre-loading RPZ zone from seed file"); try { params.zoneXFRParams.soaRecordContent = loadRPZFromFile(params.seedFileName, zone, params.defpol, params.defpolOverrideLocal, params.maxTTL); @@ -3577,13 +3469,11 @@ static void activateRPZPrimary(RPZTrackerParams& params, LuaConfigItems& lci, sh } } catch (const PDNSException& e) { - SLOG(g_log << Logger::Warning << "Unable to pre-load RPZ zone " << params.name << " from seed file '" << params.seedFileName << "': " << e.reason << endl, - log->error(Logr::Warning, e.reason, "Exception while pre-loading RPZ zone", "exception", Logging::Loggable("PDNSException"))); + log->error(Logr::Warning, e.reason, "Exception while pre-loading RPZ zone", "exception", Logging::Loggable("PDNSException")); zone->clear(); } catch (const std::exception& e) { - SLOG(g_log << Logger::Warning << "Unable to pre-load RPZ zone " << params.name << " from seed file '" << params.seedFileName << "': " << e.what() << endl, - log->error(Logr::Warning, e.what(), "Exception while pre-loading RPZ zone", "exception", Logging::Loggable("std::exception"))); + log->error(Logr::Warning, e.what(), "Exception while pre-loading RPZ zone", "exception", Logging::Loggable("std::exception")); zone->clear(); } } diff --git a/pdns/recursordist/rec-rust-lib/cxxsupport.cc b/pdns/recursordist/rec-rust-lib/cxxsupport.cc index f61add41a..31ec15dc0 100644 --- a/pdns/recursordist/rec-rust-lib/cxxsupport.cc +++ b/pdns/recursordist/rec-rust-lib/cxxsupport.cc @@ -141,8 +141,7 @@ static void mergeYamlSubFile(const std::string& configname, Recursorsettings& se } throw runtime_error("Cannot open " + configname); } - SLOG(g_log << Logger::Notice << "Processing YAML settings from " << configname << endl, - log->info(Logr::Notice, "Processing YAML settings", "path", Logging::Loggable(configname))); + log->info(Logr::Notice, "Processing YAML settings", "path", Logging::Loggable(configname)); auto data = string(std::istreambuf_iterator(file), std::istreambuf_iterator()); pdns::rust::settings::rec::merge(settings, data); } @@ -332,8 +331,7 @@ pdns::settings::rec::YamlSettingsStatus pdns::settings::rec::readYamlSettings(co msg = stringerror(errno); return YamlSettingsStatus::CannotOpen; } - SLOG(g_log << Logger::Notice << "Processing main YAML settings from " << configname << endl, - log->info(Logr::Notice, "Processing main YAML settings", "path", Logging::Loggable(configname))); + log->info(Logr::Notice, "Processing main YAML settings", "path", Logging::Loggable(configname)); try { auto data = string(std::istreambuf_iterator(file), std::istreambuf_iterator()); auto yamlstruct = pdns::rust::settings::rec::parse_yaml_string(data); @@ -369,8 +367,7 @@ pdns::settings::rec::YamlSettingsStatus pdns::settings::rec::readYamlSettings(co void pdns::settings::rec::readYamlAllowFromFile(const std::string& filename, ::rust::Vec<::rust::String>& vec, Logr::log_t log) { - SLOG(g_log << Logger::Notice << "Processing allow YAML settings from " << filename << endl, - log->info(Logr::Notice, "Processing allow YAML settings", "path", Logging::Loggable(filename))); + log->info(Logr::Notice, "Processing allow YAML settings", "path", Logging::Loggable(filename)); auto file = ifstream(filename); if (!file.is_open()) { throw runtime_error(stringerror(errno)); @@ -383,8 +380,7 @@ void pdns::settings::rec::readYamlAllowFromFile(const std::string& filename, ::r void pdns::settings::rec::readYamlForwardZonesFile(const std::string& filename, ::rust::Vec& vec, Logr::log_t log) { - SLOG(g_log << Logger::Notice << "Processing forwarding YAML settings from " << filename << endl, - log->info(Logr::Notice, "Processing forwarding YAML settings", "path", Logging::Loggable(filename))); + log->info(Logr::Notice, "Processing forwarding YAML settings", "path", Logging::Loggable(filename)); auto file = ifstream(filename); if (!file.is_open()) { throw runtime_error(stringerror(errno)); @@ -397,8 +393,7 @@ void pdns::settings::rec::readYamlForwardZonesFile(const std::string& filename, void pdns::settings::rec::readYamlAllowNotifyForFile(const std::string& filename, ::rust::Vec<::rust::String>& vec, Logr::log_t log) { - SLOG(g_log << Logger::Notice << "Processing allow-notify-for YAML settings from " << filename << endl, - log->info(Logr::Notice, "Processing allow-notify-for YAML settings", "path", Logging::Loggable(filename))); + log->info(Logr::Notice, "Processing allow-notify-for YAML settings", "path", Logging::Loggable(filename)); auto file = ifstream(filename); if (!file.is_open()) { throw runtime_error(stringerror(errno)); @@ -1411,25 +1406,21 @@ pdns::settings::rec::YamlSettingsStatus pdns::settings::rec::tryReadYAML(const s switch (yamlstatus) { case pdns::settings::rec::YamlSettingsStatus::CannotOpen: - SLOG(g_log << Logger::Debug << "No YAML config found for configname '" << yamlconfigname << "': " << msg << endl, - startupLog->error(Logr::Debug, msg, "No YAML config found", "configname", Logging::Loggable(yamlconfigname))); + startupLog->error(Logr::Debug, msg, "No YAML config found", "configname", Logging::Loggable(yamlconfigname)); break; case pdns::settings::rec::YamlSettingsStatus::PresentButFailed: - SLOG(g_log << Logger::Error << "YAML config found for configname '" << yamlconfigname << "' but error ocurred processing it" << endl, - startupLog->error(Logr::Error, msg, "YAML config found, but error occurred processing it", "configname", Logging::Loggable(yamlconfigname))); + startupLog->error(Logr::Error, msg, "YAML config found, but error occurred processing it", "configname", Logging::Loggable(yamlconfigname)); break; case pdns::settings::rec::YamlSettingsStatus::OK: yamlSettings = true; - SLOG(g_log << Logger::Notice << "YAML config found and processed for configname '" << yamlconfigname << "'" << endl, - startupLog->info(Logr::Notice, "YAML config found and processed", "configname", Logging::Loggable(yamlconfigname))); + startupLog->info(Logr::Notice, "YAML config found and processed", "configname", Logging::Loggable(yamlconfigname)); pdns::settings::rec::processAPIDir(arg()["include-dir"], settings, startupLog); luaSettingsInYAML = pdns::settings::rec::luaItemSet(settings); if (luaSettingsInYAML && !settings.recursor.lua_config_file.empty()) { const std::string err = "YAML settings include values originally in Lua but also sets `recursor.lua_config_file`. This is unsupported"; - SLOG(g_log << Logger::Error << err << endl, - startupLog->info(Logr::Error, err, "configname", Logging::Loggable(yamlconfigname))); + startupLog->info(Logr::Error, err, "configname", Logging::Loggable(yamlconfigname)); yamlstatus = pdns::settings::rec::PresentButFailed; } else if (!settings.recursor.forwarding_catalog_zones.empty() && settings.webservice.api_dir.empty()) { diff --git a/pdns/recursordist/rec-snmp.cc b/pdns/recursordist/rec-snmp.cc index 430b8a41c..6f82636fc 100644 --- a/pdns/recursordist/rec-snmp.cc +++ b/pdns/recursordist/rec-snmp.cc @@ -101,14 +101,12 @@ static int handleDisabledCounter64Stats(netsnmp_mib_handler* /* handler */, static void registerCounter64Stat(const std::string& name, const oid10& statOID) { if (statOID.size() != OID_LENGTH(questionsOID)) { - SLOG(g_log << Logger::Error << "Invalid OID for SNMP Counter64 statistic " << name << endl, - g_slog->withName("snmp")->info(Logr::Error, "Invalid OID for SNMP Counter64 statistic", "name", Logging::Loggable(name))); + g_slog->withName("snmp")->info(Logr::Error, "Invalid OID for SNMP Counter64 statistic", "name", Logging::Loggable(name)); return; } if (s_statsMap.find(statOID.at(statOID.size() - 1)) != s_statsMap.end()) { - SLOG(g_log << Logger::Error << "OID for SNMP Counter64 statistic " << name << " has already been registered" << endl, - g_slog->withName("snmp")->info(Logr::Error, "OID for SNMP Counter64 statistic has already been registered", "name", Logging::Loggable(name))); + g_slog->withName("snmp")->info(Logr::Error, "OID for SNMP Counter64 statistic has already been registered", "name", Logging::Loggable(name)); return; } diff --git a/pdns/recursordist/rec-tcp.cc b/pdns/recursordist/rec-tcp.cc index 84837293e..6d26f2b41 100644 --- a/pdns/recursordist/rec-tcp.cc +++ b/pdns/recursordist/rec-tcp.cc @@ -99,13 +99,11 @@ TCPConnection::~TCPConnection() { try { if (closesocket(d_fd) < 0) { - SLOG(g_log << Logger::Error << "Error closing socket for TCPConnection" << endl, - g_slogtcpin->info(Logr::Error, "Error closing socket for TCPConnection")); + g_slogtcpin->info(Logr::Error, "Error closing socket for TCPConnection"); } } catch (const PDNSException& e) { - SLOG(g_log << Logger::Error << "Error closing TCPConnection socket: " << e.reason << endl, - g_slogtcpin->error(Logr::Error, e.reason, "Error closing TCPConnection socket", "exception", Logging::Loggable("PDNSException"))); + g_slogtcpin->error(Logr::Error, e.reason, "Error closing TCPConnection socket", "exception", Logging::Loggable("PDNSException")); } if (t_tcpClientCounts && t_tcpClientCounts->count(d_remote) != 0 && (*t_tcpClientCounts)[d_remote]-- == 0) { @@ -255,8 +253,7 @@ static void handleNotify(std::unique_ptr& comboWriter, const DNS { if (!t_allowNotifyFrom || !t_allowNotifyFrom->match(comboWriter->d_mappedSource)) { if (!g_quiet) { - SLOG(g_log << Logger::Error << "[" << g_multiTasker->getTid() << "] dropping TCP NOTIFY from " << comboWriter->d_mappedSource.toString() << ", address not matched by allow-notify-from" << endl, - g_slogtcpin->info(Logr::Error, "Dropping TCP NOTIFY, address not matched by allow-notify-from", "source", Logging::Loggable(comboWriter->d_mappedSource))); + g_slogtcpin->info(Logr::Error, "Dropping TCP NOTIFY, address not matched by allow-notify-from", "source", Logging::Loggable(comboWriter->d_mappedSource)); } t_Counters.at(rec::Counter::sourceDisallowedNotify)++; @@ -265,8 +262,7 @@ static void handleNotify(std::unique_ptr& comboWriter, const DNS if (!isAllowNotifyForZone(qname)) { if (!g_quiet) { - SLOG(g_log << Logger::Error << "[" << g_multiTasker->getTid() << "] dropping TCP NOTIFY from " << comboWriter->d_mappedSource.toString() << ", for " << qname.toLogString() << ", zone not matched by allow-notify-for" << endl, - g_slogtcpin->info(Logr::Error, "Dropping TCP NOTIFY, zone not matched by allow-notify-for", "source", Logging::Loggable(comboWriter->d_mappedSource), "zone", Logging::Loggable(qname))); + g_slogtcpin->info(Logr::Error, "Dropping TCP NOTIFY, zone not matched by allow-notify-for", "source", Logging::Loggable(comboWriter->d_mappedSource), "zone", Logging::Loggable(qname)); } t_Counters.at(rec::Counter::zoneDisallowedNotify)++; @@ -283,8 +279,7 @@ static void doProtobufLogQuery(bool logQuery, LocalStateHolder& } catch (const std::exception& e) { if (g_logCommonErrors) { - SLOG(g_log << Logger::Warning << "Error parsing a TCP query packet for edns subnet: " << e.what() << endl, - g_slogtcpin->error(Logr::Warning, e.what(), "Error parsing a TCP query packet for edns subnet", "exception", Logging::Loggable("std::exception"), "remote", Logging::Loggable(conn->d_remote))); + g_slogtcpin->error(Logr::Warning, e.what(), "Error parsing a TCP query packet for edns subnet", "exception", Logging::Loggable("std::exception"), "remote", Logging::Loggable(conn->d_remote)); } } } @@ -395,8 +390,7 @@ static void doProcessTCPQuestion(std::unique_ptr& comboWriter, s bool ipf = t_pdl->ipfilter(comboWriter->d_source, comboWriter->d_destination, *dnsheader, comboWriter->d_eventTrace); if (ipf) { if (!g_quiet) { - SLOG(g_log << Logger::Notice << RecThreadInfo::id() << " [" << g_multiTasker->getTid() << "/" << g_multiTasker->numProcesses() << "] DROPPED TCP question from " << comboWriter->d_source.toStringWithPort() << (comboWriter->d_source != comboWriter->d_remote ? " (via " + comboWriter->d_remote.toStringWithPort() + ")" : "") << " based on policy" << endl, - g_slogtcpin->info(Logr::Info, "Dropped TCP question based on policy", "remote", Logging::Loggable(conn->d_remote), "source", Logging::Loggable(comboWriter->d_source))); + g_slogtcpin->info(Logr::Info, "Dropped TCP question based on policy", "remote", Logging::Loggable(conn->d_remote), "source", Logging::Loggable(comboWriter->d_source)); } t_Counters.at(rec::Counter::policyDrops)++; return; @@ -406,16 +400,14 @@ static void doProcessTCPQuestion(std::unique_ptr& comboWriter, s if (comboWriter->d_mdp.d_header.qr) { t_Counters.at(rec::Counter::ignoredCount)++; if (g_logCommonErrors) { - SLOG(g_log << Logger::Error << "Ignoring answer from TCP client " << comboWriter->getRemote() << " on server socket!" << endl, - g_slogtcpin->info(Logr::Error, "Ignoring answer from TCP client on server socket", "remote", Logging::Loggable(comboWriter->getRemote()))); + g_slogtcpin->info(Logr::Error, "Ignoring answer from TCP client on server socket", "remote", Logging::Loggable(comboWriter->getRemote())); } return; } if (comboWriter->d_mdp.d_header.opcode != static_cast(Opcode::Query) && comboWriter->d_mdp.d_header.opcode != static_cast(Opcode::Notify)) { t_Counters.at(rec::Counter::ignoredCount)++; if (g_logCommonErrors) { - SLOG(g_log << Logger::Error << "Ignoring unsupported opcode " << Opcode::to_s(comboWriter->d_mdp.d_header.opcode) << " from TCP client " << comboWriter->getRemote() << " on server socket!" << endl, - g_slogtcpin->info(Logr::Error, "Ignoring unsupported opcode from TCP client", "remote", Logging::Loggable(comboWriter->getRemote()), "opcode", Logging::Loggable(Opcode::to_s(comboWriter->d_mdp.d_header.opcode)))); + g_slogtcpin->info(Logr::Error, "Ignoring unsupported opcode from TCP client", "remote", Logging::Loggable(comboWriter->getRemote()), "opcode", Logging::Loggable(Opcode::to_s(comboWriter->d_mdp.d_header.opcode))); } sendErrorOverTCP(comboWriter, RCode::NotImp); tcpGuard.keep(); @@ -424,8 +416,7 @@ static void doProcessTCPQuestion(std::unique_ptr& comboWriter, s if (dnsheader->qdcount == 0U) { t_Counters.at(rec::Counter::emptyQueriesCount)++; if (g_logCommonErrors) { - SLOG(g_log << Logger::Error << "Ignoring empty (qdcount == 0) query from " << comboWriter->getRemote() << " on server socket!" << endl, - g_slogtcpin->info(Logr::Error, "Ignoring empty (qdcount == 0) query on server socket", "remote", Logging::Loggable(comboWriter->getRemote()))); + g_slogtcpin->info(Logr::Error, "Ignoring empty (qdcount == 0) query on server socket", "remote", Logging::Loggable(comboWriter->getRemote())); } sendErrorOverTCP(comboWriter, RCode::NotImp); tcpGuard.keep(); @@ -456,10 +447,9 @@ static void doProcessTCPQuestion(std::unique_ptr& comboWriter, s if (cacheHit) { if (!g_quiet) { - SLOG(g_log << Logger::Notice << RecThreadInfo::id() << " TCP question answered from packet cache tag=" << comboWriter->d_tag << " from " << comboWriter->d_source.toStringWithPort() << (comboWriter->d_source != comboWriter->d_remote ? " (via " + comboWriter->d_remote.toStringWithPort() + ")" : "") << endl, - g_slogtcpin->info(Logr::Notice, "TCP question answered from packet cache", "tag", Logging::Loggable(comboWriter->d_tag), - "qname", Logging::Loggable(qname), "qtype", Logging::Loggable(QType(qtype)), - "source", Logging::Loggable(comboWriter->d_source), "remote", Logging::Loggable(comboWriter->d_remote))); + g_slogtcpin->info(Logr::Notice, "TCP question answered from packet cache", "tag", Logging::Loggable(comboWriter->d_tag), + "qname", Logging::Loggable(qname), "qtype", Logging::Loggable(QType(qtype)), + "source", Logging::Loggable(comboWriter->d_source), "remote", Logging::Loggable(comboWriter->d_remote)); } bool hadError = sendResponseOverTCP(comboWriter, response); @@ -477,8 +467,7 @@ static void doProcessTCPQuestion(std::unique_ptr& comboWriter, s } if (comboWriter->d_eventTrace.enabled() && SyncRes::eventTraceEnabled(SyncRes::event_trace_to_log)) { - SLOG(g_log << Logger::Info << comboWriter->d_eventTrace.toString() << endl, - g_slogtcpin->info(Logr::Info, comboWriter->d_eventTrace.toString())); // More fancy? + g_slogtcpin->info(Logr::Info, comboWriter->d_eventTrace.toString()); // More fancy? } tcpGuard.keep(); t_Counters.updateSnap(g_regressionTestMode); @@ -488,8 +477,7 @@ static void doProcessTCPQuestion(std::unique_ptr& comboWriter, s if (comboWriter->d_mdp.d_header.opcode == static_cast(Opcode::Notify)) { if (!g_quiet) { - SLOG(g_log << Logger::Notice << RecThreadInfo::id() << " got NOTIFY for " << qname.toLogString() << " from " << comboWriter->d_source.toStringWithPort() << (comboWriter->d_source != comboWriter->d_remote ? " (via " + comboWriter->d_remote.toStringWithPort() + ")" : "") << endl, - g_slogtcpin->info(Logr::Notice, "Got NOTIFY", "qname", Logging::Loggable(qname), "source", Logging::Loggable(comboWriter->d_source), "remote", Logging::Loggable(comboWriter->d_remote))); + g_slogtcpin->info(Logr::Notice, "Got NOTIFY", "qname", Logging::Loggable(qname), "source", Logging::Loggable(comboWriter->d_source), "remote", Logging::Loggable(comboWriter->d_remote)); } requestWipeCaches(qname); @@ -534,8 +522,7 @@ static void handleRunningTCPQuestion(int fileDesc, FDMultiplexer::funcparam_t& v ssize_t remaining = isProxyHeaderComplete(conn->data); if (remaining == 0) { if (g_logCommonErrors) { - SLOG(g_log << Logger::Error << "Unable to consume proxy protocol header in packet from TCP client " << conn->d_remote.toStringWithPort() << endl, - g_slogtcpin->info(Logr::Error, "Unable to consume proxy protocol header in packet from TCP client", "remote", Logging::Loggable(conn->d_remote))); + g_slogtcpin->info(Logr::Error, "Unable to consume proxy protocol header in packet from TCP client", "remote", Logging::Loggable(conn->d_remote)); } ++t_Counters.at(rec::Counter::proxyProtocolInvalidCount); return; @@ -555,16 +542,14 @@ static void handleRunningTCPQuestion(int fileDesc, FDMultiplexer::funcparam_t& v size_t used = parseProxyHeader(conn->data, proxy, conn->d_source, conn->d_destination, tcp, conn->proxyProtocolValues); if (used <= 0) { if (g_logCommonErrors) { - SLOG(g_log << Logger::Error << "Unable to parse proxy protocol header in packet from TCP client " << conn->d_remote.toStringWithPort() << endl, - g_slogtcpin->info(Logr::Error, "Unable to parse proxy protocol header in packet from TCP client", "remote", Logging::Loggable(conn->d_remote))); + g_slogtcpin->info(Logr::Error, "Unable to parse proxy protocol header in packet from TCP client", "remote", Logging::Loggable(conn->d_remote)); } ++t_Counters.at(rec::Counter::proxyProtocolInvalidCount); return; } if (static_cast(used) > g_proxyProtocolMaximumSize) { if (g_logCommonErrors) { - SLOG(g_log << Logger::Error << "Proxy protocol header in packet from TCP client " << conn->d_remote.toStringWithPort() << " is larger than proxy-protocol-maximum-size (" << used << "), dropping" << endl, - g_slogtcpin->info(Logr::Error, "Proxy protocol header in packet from TCP client is larger than proxy-protocol-maximum-size", "remote", Logging::Loggable(conn->d_remote), "size", Logging::Loggable(used))); + g_slogtcpin->info(Logr::Error, "Proxy protocol header in packet from TCP client is larger than proxy-protocol-maximum-size", "remote", Logging::Loggable(conn->d_remote), "size", Logging::Loggable(used)); } ++t_Counters.at(rec::Counter::proxyProtocolInvalidCount); return; @@ -585,8 +570,7 @@ static void handleRunningTCPQuestion(int fileDesc, FDMultiplexer::funcparam_t& v } if (t_allowFrom && !t_allowFrom->match(&conn->d_mappedSource)) { if (!g_quiet) { - SLOG(g_log << Logger::Error << "[" << g_multiTasker->getTid() << "] dropping TCP query from " << conn->d_mappedSource.toString() << ", address not matched by allow-from" << endl, - g_slogtcpin->info(Logr::Error, "Dropping TCP query, address not matched by allow-from", "remote", Logging::Loggable(conn->d_remote))); + g_slogtcpin->info(Logr::Error, "Dropping TCP query, address not matched by allow-from", "remote", Logging::Loggable(conn->d_remote)); } ++t_Counters.at(rec::Counter::unauthorizedTCP); @@ -626,8 +610,7 @@ static void handleRunningTCPQuestion(int fileDesc, FDMultiplexer::funcparam_t& v if (bytes <= 0) { if (!tcpGuard.handleTCPReadResult(fileDesc, bytes)) { if (g_logCommonErrors) { - SLOG(g_log << Logger::Error << "TCP client " << conn->d_remote.toStringWithPort() << " disconnected after first byte" << endl, - g_slogtcpin->info(Logr::Error, "TCP client disconnected after first byte", "remote", Logging::Loggable(conn->d_remote))); + g_slogtcpin->info(Logr::Error, "TCP client disconnected after first byte", "remote", Logging::Loggable(conn->d_remote)); } } return; @@ -639,16 +622,14 @@ static void handleRunningTCPQuestion(int fileDesc, FDMultiplexer::funcparam_t& v if (bytes <= 0) { if (!tcpGuard.handleTCPReadResult(fileDesc, bytes)) { if (g_logCommonErrors) { - SLOG(g_log << Logger::Error << "TCP client " << conn->d_remote.toStringWithPort() << " disconnected while reading question body" << endl, - g_slogtcpin->info(Logr::Error, "TCP client disconnected while reading question body", "remote", Logging::Loggable(conn->d_remote))); + g_slogtcpin->info(Logr::Error, "TCP client disconnected while reading question body", "remote", Logging::Loggable(conn->d_remote)); } } return; } if (bytes > std::numeric_limits::max()) { if (g_logCommonErrors) { - SLOG(g_log << Logger::Error << "TCP client " << conn->d_remote.toStringWithPort() << " sent an invalid question size while reading question body" << endl, - g_slogtcpin->info(Logr::Error, "TCP client sent an invalid question size while reading question body", "remote", Logging::Loggable(conn->d_remote))); + g_slogtcpin->info(Logr::Error, "TCP client sent an invalid question size while reading question body", "remote", Logging::Loggable(conn->d_remote)); } return; } @@ -662,8 +643,7 @@ static void handleRunningTCPQuestion(int fileDesc, FDMultiplexer::funcparam_t& v catch (const MOADNSException& mde) { t_Counters.at(rec::Counter::clientParseError)++; if (g_logCommonErrors) { - SLOG(g_log << Logger::Error << "Unable to parse packet from TCP client " << conn->d_remote.toStringWithPort() << endl, - g_slogtcpin->info(Logr::Error, "Unable to parse packet from TCP client", "remte", Logging::Loggable(conn->d_remote))); + g_slogtcpin->info(Logr::Error, "Unable to parse packet from TCP client", "remte", Logging::Loggable(conn->d_remote)); } return; } @@ -738,8 +718,7 @@ void handleNewTCPQuestion(int fileDesc, [[maybe_unused]] FDMultiplexer::funcpara } if (!fromProxyProtocolSource && t_allowFrom && !t_allowFrom->match(&mappedSource)) { if (!g_quiet) { - SLOG(g_log << Logger::Error << "[" << g_multiTasker->getTid() << "] dropping TCP query from " << mappedSource.toString() << ", address neither matched by allow-from nor proxy-protocol-from" << endl, - g_slogtcpin->info(Logr::Error, "dropping TCP query address neither matched by allow-from nor proxy-protocol-from", "source", Logging::Loggable(mappedSource))); + g_slogtcpin->info(Logr::Error, "dropping TCP query address neither matched by allow-from nor proxy-protocol-from", "source", Logging::Loggable(mappedSource)); } closeSock(rec::Counter::unauthorizedTCP, "Error closing TCP socket after an ACL drop"); return; @@ -940,21 +919,17 @@ void checkFastOpenSysctl([[maybe_unused]] bool active, [[maybe_unused]] Logr::lo if (readFileIfThere("/proc/sys/net/ipv4/tcp_fastopen", &line)) { int flag = std::stoi(line); if (active && !(flag & 1)) { - SLOG(g_log << Logger::Error << "tcp-fast-open-connect enabled but net.ipv4.tcp_fastopen does not allow it" << endl, - log->info(Logr::Error, "tcp-fast-open-connect enabled but net.ipv4.tcp_fastopen does not allow it")); + log->info(Logr::Error, "tcp-fast-open-connect enabled but net.ipv4.tcp_fastopen does not allow it"); } if (!active && !(flag & 2)) { - SLOG(g_log << Logger::Error << "tcp-fast-open enabled but net.ipv4.tcp_fastopen does not allow it" << endl, - log->info(Logr::Error, "tcp-fast-open enabled but net.ipv4.tcp_fastopen does not allow it")); + log->info(Logr::Error, "tcp-fast-open enabled but net.ipv4.tcp_fastopen does not allow it"); } } else { - SLOG(g_log << Logger::Notice << "Cannot determine if kernel settings allow fast-open" << endl, - log->info(Logr::Notice, "Cannot determine if kernel settings allow fast-open")); + log->info(Logr::Notice, "Cannot determine if kernel settings allow fast-open"); } #else - SLOG(g_log << Logger::Notice << "Cannot determine if kernel settings allow fast-open" << endl, - log->info(Logr::Notice, "Cannot determine if kernel settings allow fast-open")); + log->info(Logr::Notice, "Cannot determine if kernel settings allow fast-open"); #endif } @@ -966,8 +941,7 @@ void checkTFOconnect(Logr::log_t log) socket.setFastOpenConnect(); } catch (const NetworkError& e) { - SLOG(g_log << Logger::Error << "tcp-fast-open-connect enabled but returned error: " << e.what() << endl, - log->error(Logr::Error, e.what(), "tcp-fast-open-connect enabled but returned error")); + log->error(Logr::Error, e.what(), "tcp-fast-open-connect enabled but returned error"); } } @@ -1122,21 +1096,18 @@ unsigned int makeTCPServerSockets(deferredAdd_t& deferredAdds, std::set& tc int tmp = 1; if (setsockopt(socketFd, SOL_SOCKET, SO_REUSEADDR, &tmp, sizeof tmp) < 0) { int err = errno; - SLOG(g_log << Logger::Error << "Setsockopt failed for TCP listening socket" << endl, - log->error(Logr::Critical, err, "Setsockopt failed for TCP listening socket")); + log->error(Logr::Critical, err, "Setsockopt failed for TCP listening socket"); _exit(1); } if (address.sin6.sin6_family == AF_INET6 && setsockopt(socketFd, IPPROTO_IPV6, IPV6_V6ONLY, &tmp, sizeof(tmp)) < 0) { int err = errno; - SLOG(g_log << Logger::Error << "Failed to set IPv6 socket to IPv6 only, continuing anyhow: " << stringerror(err) << endl, - log->error(Logr::Warning, err, "Failed to set IPv6 socket to IPv6 only, continuing anyhow")); + log->error(Logr::Warning, err, "Failed to set IPv6 socket to IPv6 only, continuing anyhow"); } #ifdef TCP_DEFER_ACCEPT if (setsockopt(socketFd, IPPROTO_TCP, TCP_DEFER_ACCEPT, &tmp, sizeof tmp) >= 0) { if (first) { - SLOG(g_log << Logger::Info << "Enabled TCP data-ready filter for (slight) DoS protection" << endl, - log->info(Logr::Info, "Enabled TCP data-ready filter for (slight) DoS protection")); + log->info(Logr::Info, "Enabled TCP data-ready filter for (slight) DoS protection"); } } #endif @@ -1168,12 +1139,10 @@ unsigned int makeTCPServerSockets(deferredAdd_t& deferredAdds, std::set& tc #ifdef TCP_FASTOPEN if (setsockopt(socketFd, IPPROTO_TCP, TCP_FASTOPEN, &SyncRes::s_tcp_fast_open, sizeof SyncRes::s_tcp_fast_open) < 0) { int err = errno; - SLOG(g_log << Logger::Error << "Failed to enable TCP Fast Open for listening socket: " << stringerror(err) << endl, - log->error(Logr::Error, err, "Failed to enable TCP Fast Open for listening socket")); + log->error(Logr::Error, err, "Failed to enable TCP Fast Open for listening socket"); } #else - SLOG(g_log << Logger::Warning << "TCP Fast Open configured but not supported for listening socket" << endl, - log->info(Logr::Warning, "TCP Fast Open configured but not supported for listening socket")); + log->info(Logr::Warning, "TCP Fast Open configured but not supported for listening socket"); #endif } @@ -1192,8 +1161,7 @@ unsigned int makeTCPServerSockets(deferredAdd_t& deferredAdds, std::set& tc setSocketSendBuffer(socketFd, 65000); } catch (const std::exception& e) { - SLOG(g_log << Logger::Error << e.what() << endl, - log->error(Logr::Error, e.what(), "Exception while setting socket send buffer")); + log->error(Logr::Error, e.what(), "Exception while setting socket send buffer"); } listen(socketFd, 128); diff --git a/pdns/recursordist/rec_channel_rec.cc b/pdns/recursordist/rec_channel_rec.cc index 5a65eae9c..0289388fa 100644 --- a/pdns/recursordist/rec_channel_rec.cc +++ b/pdns/recursordist/rec_channel_rec.cc @@ -1970,8 +1970,7 @@ RecursorControlChannel::Answer luaconfig(bool broadcast) g_proxyMapping = proxyMapping.empty() ? nullptr : std::make_unique(proxyMapping); } if (broadcast) { - SLOG(g_log << Logger::Notice << "Reloaded Lua configuration file '" << ::arg()["lua-config-file"] << "', requested via control channel" << endl, - g_slog->withName("config")->info(Logr::Info, "Reloaded")); + g_slog->withName("config")->info(Logr::Info, "Reloaded"); } return {0, "Reloaded Lua configuration file '" + ::arg()["lua-config-file"] + "'\n"}; } diff --git a/pdns/recursordist/reczones-helpers.cc b/pdns/recursordist/reczones-helpers.cc index 82ed158f1..a0d61d8b7 100644 --- a/pdns/recursordist/reczones-helpers.cc +++ b/pdns/recursordist/reczones-helpers.cc @@ -104,18 +104,15 @@ bool readHintsIntoCache(time_t now, const std::string& hintfile, std::vectorwithName("config"); if (SyncRes::s_doIPv4 && !SyncRes::s_doIPv6 && !reachableA) { - SLOG(g_log << Logger::Error << "Running IPv4 only but no IPv4 root hints" << endl, - log->info(Logr::Error, "Running IPv4 only but no IPv4 root hints")); + log->info(Logr::Error, "Running IPv4 only but no IPv4 root hints"); return false; } if (!SyncRes::s_doIPv4 && SyncRes::s_doIPv6 && !reachableAAAA) { - SLOG(g_log << Logger::Error << "Running IPv6 only but no IPv6 root hints" << endl, - log->info(Logr::Error, "Running IPv6 only but no IPv6 root hints")); + log->info(Logr::Error, "Running IPv6 only but no IPv6 root hints"); return false; } if (SyncRes::s_doIPv4 && SyncRes::s_doIPv6 && !reachableA && !reachableAAAA) { - SLOG(g_log << Logger::Error << "No valid root hints" << endl, - log->info(Logr::Error, "No valid root hints")); + log->info(Logr::Error, "No valid root hints"); return false; } return true; @@ -198,15 +195,13 @@ static void addToDomainMap(SyncRes::domainmap_t& newMap, const bool reverse = false) { if (newMap.count(name) != 0) { - SLOG(g_log << Logger::Warning << "Will not overwrite zone '" << name << "' already loaded" << endl, - log->info(Logr::Warning, "Will not overwrite already loaded zone", "zone", - Logging::Loggable(name))); + log->info(Logr::Warning, "Will not overwrite already loaded zone", "zone", + Logging::Loggable(name)); } else { if (!partial) { const auto direction = reverse ? std::string{"reverse"} : std::string{"forward"}; - SLOG(g_log << Logger::Warning << "Inserting " << direction << " zone '" << name << "' based on hosts file" << endl, - log->info(Logr::Notice, "Inserting " + direction + " zone based on hosts file", "zone", Logging::Loggable(name))); + log->info(Logr::Notice, "Inserting " + direction + " zone based on hosts file", "zone", Logging::Loggable(name)); } ad.d_name = name; newMap[ad.d_name] = ad; diff --git a/pdns/recursordist/reczones.cc b/pdns/recursordist/reczones.cc index 6129f21aa..fea92f138 100644 --- a/pdns/recursordist/reczones.cc +++ b/pdns/recursordist/reczones.cc @@ -44,8 +44,7 @@ bool primeHints(time_t now) if (hintfile == "no" || hintfile == "no-refresh") { auto log = g_slog->withName("config"); - SLOG(g_log << Logger::Debug << "Priming root disabled by hint-file setting" << endl, - log->info(Logr::Debug, "Priming root disabled by hint-file setting")); + log->info(Logr::Debug, "Priming root disabled by hint-file setting"); return ret; } @@ -120,8 +119,7 @@ string reloadZoneConfiguration(bool yaml) cleanSlashes(configname); try { - SLOG(g_log << Logger::Warning << "Reloading zones, purging data from cache" << endl, - log->info(Logr::Notice, "Reloading zones, purging data from cache")); + log->info(Logr::Notice, "Reloading zones, purging data from cache"); if (yaml) { configname += g_yamlSettingsSuffix; @@ -223,24 +221,20 @@ string reloadZoneConfiguration(bool yaml) return "ok\n"; } catch (const std::exception& e) { - SLOG(g_log << Logger::Error << "Encountered error reloading zones, keeping original data: " << e.what() << endl, - log->error(Logr::Error, e.what(), "Encountered error reloading zones, keeping original data")); + log->error(Logr::Error, e.what(), "Encountered error reloading zones, keeping original data"); } catch (const PDNSException& ae) { - SLOG(g_log << Logger::Error << "Encountered error reloading zones, keeping original data: " << ae.reason << endl, - log->error(Logr::Error, ae.reason, "Encountered error reloading zones, keeping original data")); + log->error(Logr::Error, ae.reason, "Encountered error reloading zones, keeping original data"); } catch (...) { - SLOG(g_log << Logger::Error << "Encountered unknown error reloading zones, keeping original data" << endl, - log->error(Logr::Error, "Exception", "Encountered error reloading zones, keeping original data")); + log->error(Logr::Error, "Exception", "Encountered error reloading zones, keeping original data"); } return "reloading failed, see log\n"; } static void readAuthZoneData(SyncRes::AuthDomain& authDomain, const pair& headers, Logr::log_t log) { - SLOG(g_log << Logger::Notice << "Parsing authoritative data for zone '" << headers.first << "' from file '" << headers.second << "'" << endl, - log->info(Logr::Notice, "Parsing authoritative data from file", "zone", Logging::Loggable(headers.first), "file", Logging::Loggable(headers.second))); + log->info(Logr::Notice, "Parsing authoritative data from file", "zone", Logging::Loggable(headers.first), "file", Logging::Loggable(headers.second)); ZoneParserTNG zpt(headers.second, DNSName(headers.first)); zpt.setMaxGenerateSteps(::arg().asNum("max-generate-steps")); zpt.setMaxIncludes(::arg().asNum("max-include-depth")); @@ -305,8 +299,7 @@ static void processApiZonesFile(const string& file, shared_ptrinfo(Logr::Notice, "Processing ApiZones YAML settings", "path", Logging::Loggable(filename))); + log->info(Logr::Notice, "Processing ApiZones YAML settings", "path", Logging::Loggable(filename)); const uint64_t before = newMap->size(); @@ -332,12 +325,9 @@ static void processApiZonesFile(const string& file, shared_ptrsize() - before - << " ApiZones YAML settings from file '" - << filename << "'" << endl, - log->info(Logr::Notice, "Done parsing ApiZones YAML from file", "file", - Logging::Loggable(filename), "count", - Logging::Loggable(newMap->size() - before))); + log->info(Logr::Notice, "Done parsing ApiZones YAML from file", "file", + Logging::Loggable(filename), "count", + Logging::Loggable(newMap->size() - before)); } static void processForwardZonesFile(shared_ptr& newMap, shared_ptr& newSet, Logr::log_t log) @@ -366,8 +356,7 @@ static void processForwardZonesFile(shared_ptr& newMap, sh } } else { - SLOG(g_log << Logger::Warning << "Reading zone forwarding information from '" << filename << "'" << endl, - log->info(Logr::Notice, "Reading zone forwarding information", "file", Logging::Loggable(filename))); + log->info(Logr::Notice, "Reading zone forwarding information", "file", Logging::Loggable(filename)); auto filePtr = pdns::UniqueFilePtr(fopen(filename.c_str(), "r")); if (!filePtr) { int err = errno; @@ -430,12 +419,9 @@ static void processForwardZonesFile(shared_ptr& newMap, sh } } } - SLOG(g_log << Logger::Warning << "Done parsing " << newMap->size() - before - << " forwarding instructions from file '" - << filename << "'" << endl, - log->info(Logr::Notice, "Done parsing forwarding instructions from file", "file", - Logging::Loggable(filename), "count", - Logging::Loggable(newMap->size() - before))); + log->info(Logr::Notice, "Done parsing forwarding instructions from file", "file", + Logging::Loggable(filename), "count", + Logging::Loggable(newMap->size() - before)); } static void processExportEtcHosts(std::shared_ptr& newMap, Logr::log_t log) @@ -446,8 +432,7 @@ static void processExportEtcHosts(std::shared_ptr& newMap, string fname = ::arg()["etc-hosts-file"]; ifstream ifs(fname); if (!ifs) { - SLOG(g_log << Logger::Warning << "Could not open " << fname << " for reading" << endl, - log->error(Logr::Warning, "Could not open file for reading", "file", Logging::Loggable(fname))); + log->error(Logr::Warning, "Could not open file for reading", "file", Logging::Loggable(fname)); return; } vector parts; @@ -462,15 +447,10 @@ static void processExportEtcHosts(std::shared_ptr& newMap, addForwardAndReverseLookupEntries(*newMap, searchSuffix, parts, log); } catch (const PDNSException& ex) { - SLOG(g_log << Logger::Warning - << "The line `" << line << "` " - << "in the provided etc-hosts file `" << fname << "` " - << "could not be added: " << ex.reason << ". Going to skip it." - << endl, - log->info(Logr::Notice, "Skipping line in etc-hosts file", - "line", Logging::Loggable(line), - "hosts-file", Logging::Loggable(fname), - "reason", Logging::Loggable(ex.reason))); + log->info(Logr::Notice, "Skipping line in etc-hosts file", + "line", Logging::Loggable(line), + "hosts-file", Logging::Loggable(fname), + "reason", Logging::Loggable(ex.reason)); } } } @@ -480,8 +460,7 @@ static void processServeRFC1918(std::shared_ptr& newMap, L if (!::arg().mustDo("serve-rfc1918")) { return; } - SLOG(g_log << Logger::Warning << "Inserting rfc 1918 private space zones" << endl, - log->info(Logr::Notice, "Inserting rfc 1918 private space zones")); + log->info(Logr::Notice, "Inserting rfc 1918 private space zones"); makePartialIPZone(*newMap, {"127"}, log); makePartialIPZone(*newMap, {"10"}, log); @@ -500,8 +479,7 @@ static void processServeRFC6303(std::shared_ptr& newMap, L if (!::arg().mustDo("serve-rfc1918")) { return; } - SLOG(g_log << Logger::Warning << "Inserting rfc 6303 private space zones" << endl, - log->info(Logr::Notice, "Inserting rfc 6303 private space zones")); + log->info(Logr::Notice, "Inserting rfc 6303 private space zones"); // Section 4.2 makePartialIPZone(*newMap, {"0"}, log); // makePartialIPZone(*newMap, { "127" }, log) already done in processServeRFC1918 @@ -550,8 +528,7 @@ static void processAllowNotifyForFile(shared_ptr& newSet, Logr::log } } else { - SLOG(g_log << Logger::Warning << "Reading NOTIFY-allowed zones from '" << filename << "'" << endl, - log->info(Logr::Notice, "Reading NOTIFY-allowed zones from file", "file", Logging::Loggable(filename))); + log->info(Logr::Notice, "Reading NOTIFY-allowed zones from file", "file", Logging::Loggable(filename)); auto filePtr = pdns::UniqueFilePtr(fopen(filename.c_str(), "r")); if (!filePtr) { throw PDNSException("Error opening allow-notify-for-file '" + filename + "': " + stringerror()); @@ -566,8 +543,7 @@ static void processAllowNotifyForFile(shared_ptr& newSet, Logr::log newSet->insert(DNSName(line)); } } - SLOG(g_log << Logger::Warning << "Done parsing " << newSet->size() - before << " NOTIFY-allowed zones from file '" << filename << "'" << endl, - log->info(Logr::Notice, "Done parsing NOTIFY-allowed zones from file", "file", Logging::Loggable(filename), "count", Logging::Loggable(newSet->size() - before))); + log->info(Logr::Notice, "Done parsing NOTIFY-allowed zones from file", "file", Logging::Loggable(filename), "count", Logging::Loggable(newSet->size() - before)); } std::tuple, std::shared_ptr> parseZoneConfiguration(bool yaml) diff --git a/pdns/recursordist/rpzloader.cc b/pdns/recursordist/rpzloader.cc index 720340e10..95cced490 100644 --- a/pdns/recursordist/rpzloader.cc +++ b/pdns/recursordist/rpzloader.cc @@ -147,8 +147,7 @@ static void RPZRecordToPolicy(const DNSRecord& dnsRecord, const std::shared_ptr< else if (!crcTarget.empty() && !crcTarget.isRoot() && crcTarget.getRawLabel(crcTarget.countLabels() - 1).compare(0, rpzPrefix.length(), rpzPrefix) == 0) { /* this is very likely an higher format number or a configuration error, let's just ignore it. */ - SLOG(g_log << Logger::Info << "Discarding unsupported RPZ entry " << crcTarget << " for " << dnsRecord.d_name << endl, - log->info(Logr::Info, "Discarding unsupported RPZ entry", "target", Logging::Loggable(crcTarget), "name", Logging::Loggable(dnsRecord.d_name))); + log->info(Logr::Info, "Discarding unsupported RPZ entry", "target", Logging::Loggable(crcTarget), "name", Logging::Loggable(dnsRecord.d_name)); return; } else { @@ -241,11 +240,9 @@ static shared_ptr loadRPZFromServer(Logr::log_t plogger, { auto logger = plogger->withValues("primary", Logging::Loggable(primary)); - SLOG(g_log << Logger::Warning << "Loading RPZ zone '" << zoneName << "' from " << primary.toStringWithPort() << endl, - logger->info(Logr::Info, "Loading RPZ from nameserver")); + logger->info(Logr::Info, "Loading RPZ from nameserver"); if (!tsigTriplet.name.empty()) { - SLOG(g_log << Logger::Warning << "With TSIG key '" << tsigTriplet.name << "' of algorithm '" << tsigTriplet.algo << "'" << endl, - logger->info(Logr::Info, "Using TSIG key for authentication", "tsig_key_name", Logging::Loggable(tsigTriplet.name), "tsig_key_algorithm", Logging::Loggable(tsigTriplet.algo))); + logger->info(Logr::Info, "Using TSIG key for authentication", "tsig_key_name", Logging::Loggable(tsigTriplet.name), "tsig_key_algorithm", Logging::Loggable(tsigTriplet.algo)); } ComboAddress local(localAddress); @@ -286,13 +283,11 @@ static shared_ptr loadRPZFromServer(Logr::log_t plogger, throw PDNSException("Total AXFR time exceeded!"); } if (last != time(nullptr)) { - SLOG(g_log << Logger::Info << "Loaded & indexed " << nrecords << " policy records so far for RPZ zone '" << zoneName << "'" << endl, - logger->info(Logr::Info, "RPZ load in progress", "nrecords", Logging::Loggable(nrecords))); + logger->info(Logr::Info, "RPZ load in progress", "nrecords", Logging::Loggable(nrecords)); last = time(nullptr); } } - SLOG(g_log << Logger::Info << "Done: " << nrecords << " policy records active, SOA: " << soaRecordContent->getZoneRepresentation() << endl, - logger->info(Logr::Info, "RPZ load completed", "nrecords", Logging::Loggable(nrecords), "soa", Logging::Loggable(soaRecordContent->getZoneRepresentation()))); + logger->info(Logr::Info, "RPZ load completed", "nrecords", Logging::Loggable(nrecords), "soa", Logging::Loggable(soaRecordContent->getZoneRepresentation())); return soaRecordContent; } @@ -413,8 +408,7 @@ static bool dumpZoneToDisk(Logr::log_t logger, const std::shared_ptrdata()); if (fileDesc < 0) { - SLOG(g_log << Logger::Warning << "Unable to open a file to dump the content of the RPZ zone " << zoneName << endl, - logger->error(Logr::Error, errno, "Unable to create temporary file")); + logger->error(Logr::Error, errno, "Unable to create temporary file"); tempFile->clear(); // file has not been created, no need to unlink return false; } @@ -423,8 +417,7 @@ static bool dumpZoneToDisk(Logr::log_t logger, const std::shared_ptrerror(Logr::Error, err, "Unable to open file pointer")); + logger->error(Logr::Error, err, "Unable to open file pointer"); return false; } @@ -432,32 +425,27 @@ static bool dumpZoneToDisk(Logr::log_t logger, const std::shared_ptrdump(filePtr.get()); } catch (const std::exception& e) { - SLOG(g_log << Logger::Warning << "Error while dumping the content of the RPZ zone " << zoneName << ": " << e.what() << endl, - logger->error(Logr::Error, e.what(), "Error while dumping the content of the RPZ")); + logger->error(Logr::Error, e.what(), "Error while dumping the content of the RPZ"); return false; } if (fflush(filePtr.get()) != 0) { - SLOG(g_log << Logger::Warning << "Error while flushing the content of the RPZ zone " << zoneName << " to the dump file: " << stringerror() << endl, - logger->error(Logr::Warning, errno, "Error while flushing the content of the RPZ")); + logger->error(Logr::Warning, errno, "Error while flushing the content of the RPZ"); return false; } if (fsync(fileno(filePtr.get())) != 0) { - SLOG(g_log << Logger::Warning << "Error while syncing the content of the RPZ zone " << zoneName << " to the dump file: " << stringerror() << endl, - logger->error(Logr::Error, errno, "Error while syncing the content of the RPZ")); + logger->error(Logr::Error, errno, "Error while syncing the content of the RPZ"); return false; } if (fclose(filePtr.release()) != 0) { - SLOG(g_log << Logger::Warning << "Error while writing the content of the RPZ zone " << zoneName << " to the dump file: " << stringerror() << endl, - logger->error(Logr::Error, errno, "Error while writing the content of the RPZ")); + logger->error(Logr::Error, errno, "Error while writing the content of the RPZ"); return false; } if (rename(tempFile->c_str(), dumpZoneFileName.c_str()) != 0) { - SLOG(g_log << Logger::Warning << "Error while moving the content of the RPZ zone " << zoneName << " to the dump file: " << stringerror() << endl, - logger->error(Logr::Error, errno, "Error while moving the content of the RPZ", "destination_file", Logging::Loggable(dumpZoneFileName))); + logger->error(Logr::Error, errno, "Error while moving the content of the RPZ", "destination_file", Logging::Loggable(dumpZoneFileName)); return false; } tempFile->clear(); // file has been renamed, no need to unlink @@ -492,13 +480,11 @@ static void preloadRPZFIle(RPZTrackerParams& params, const DNSName& zoneName, st break; } catch (const std::exception& e) { - SLOG(g_log << Logger::Warning << "Unable to load RPZ zone '" << zoneName << "' from '" << primary << "': '" << e.what() << "'. (Will try again in " << refresh << " seconds...)" << endl, - logger->error(Logr::Warning, e.what(), "Unable to load RPZ zone, will retry", "from", Logging::Loggable(primary), "exception", Logging::Loggable("std::exception"), "refresh", Logging::Loggable(refresh))); + logger->error(Logr::Warning, e.what(), "Unable to load RPZ zone, will retry", "from", Logging::Loggable(primary), "exception", Logging::Loggable("std::exception"), "refresh", Logging::Loggable(refresh)); incRPZFailedTransfers(polName); } catch (const PDNSException& e) { - SLOG(g_log << Logger::Warning << "Unable to load RPZ zone '" << zoneName << "' from '" << primary << "': '" << e.reason << "'. (Will try again in " << refresh << " seconds...)" << endl, - logger->error(Logr::Warning, e.reason, "Unable to load RPZ zone, will retry", "from", Logging::Loggable(primary), "exception", Logging::Loggable("PDNSException"), "refresh", Logging::Loggable(refresh))); + logger->error(Logr::Warning, e.reason, "Unable to load RPZ zone, will retry", "from", Logging::Loggable(primary), "exception", Logging::Loggable("PDNSException"), "refresh", Logging::Loggable(refresh)); incRPZFailedTransfers(polName); } } @@ -553,8 +539,7 @@ static bool RPZTrackerIteration(RPZTrackerParams& params, const DNSName& zoneNam /* the configuration has been reloaded, meaning that a new thread has been started to handle that zone and we are now obsolete. */ - SLOG(g_log << Logger::Info << "A more recent configuration has been found, stopping the existing RPZ update thread for " << zoneName << endl, - logger->info(Logr::Info, "A more recent configuration has been found, stopping the existing RPZ update thread")); + logger->info(Logr::Info, "A more recent configuration has been found, stopping the existing RPZ update thread"); return false; } @@ -563,8 +548,7 @@ static bool RPZTrackerIteration(RPZTrackerParams& params, const DNSName& zoneNam auto primary = pdns::fromNameOrIP(ipOrName, 53, logger); auto soa = getRR(dnsRecord); auto serial = soa ? soa->d_st.serial : 0; - SLOG(g_log << Logger::Info << "Getting IXFR deltas for " << zoneName << " from " << primary.toStringWithPort() << ", our serial: " << serial << endl, - logger->info(Logr::Info, "Getting IXFR deltas", "address", Logging::Loggable(primary), "ourserial", Logging::Loggable(serial))); + logger->info(Logr::Info, "Getting IXFR deltas", "address", Logging::Loggable(primary), "ourserial", Logging::Loggable(serial)); ComboAddress local(params.zoneXFRParams.localAddress); if (local == ComboAddress()) { @@ -578,8 +562,7 @@ static bool RPZTrackerIteration(RPZTrackerParams& params, const DNSName& zoneNam break; } catch (const std::runtime_error& e) { - SLOG(g_log << Logger::Warning << e.what() << endl, - logger->error(Logr::Warning, e.what(), "Exception during retrieval of delta", "exception", Logging::Loggable("std::runtime_error"))); + logger->error(Logr::Warning, e.what(), "Exception during retrieval of delta", "exception", Logging::Loggable("std::runtime_error")); incRPZFailedTransfers(polName); continue; } @@ -590,18 +573,15 @@ static bool RPZTrackerIteration(RPZTrackerParams& params, const DNSName& zoneNam } try { - SLOG(g_log << Logger::Info << "Processing " << deltas.size() << " delta" << addS(deltas) << " for RPZ " << zoneName << endl, - logger->info(Logr::Info, "Processing deltas", "size", Logging::Loggable(deltas.size()))); + logger->info(Logr::Info, "Processing deltas", "size", Logging::Loggable(deltas.size())); if (luaconfsLocal->generation != configGeneration) { - SLOG(g_log << Logger::Info << "A more recent configuration has been found, stopping the existing RPZ update thread for " << zoneName << endl, - logger->info(Logr::Info, "A more recent configuration has been found, stopping the existing RPZ update thread")); + logger->info(Logr::Info, "A more recent configuration has been found, stopping the existing RPZ update thread"); return false; } oldZone = luaconfsLocal->dfe.getZone(params.zoneXFRParams.zoneIdx); if (!oldZone || oldZone->getDomain() != zoneName) { - SLOG(g_log << Logger::Info << "This policy is no more, stopping the existing RPZ update thread for " << zoneName << endl, - logger->info(Logr::Info, "This policy is no more, stopping the existing RPZ update thread")); + logger->info(Logr::Info, "This policy is no more, stopping the existing RPZ update thread"); return false; } /* we need to make a _full copy_ of the zone we are going to work on */ @@ -616,8 +596,7 @@ static bool RPZTrackerIteration(RPZTrackerParams& params, const DNSName& zoneNam const auto& remove = delta.first; const auto& add = delta.second; if (remove.empty()) { - SLOG(g_log << Logger::Warning << "IXFR update is a whole new zone" << endl, - logger->info(Logr::Warning, "IXFR update is a whole new zone")); + logger->info(Logr::Warning, "IXFR update is a whole new zone"); newZone->clear(); fullUpdate = true; } @@ -639,8 +618,7 @@ static bool RPZTrackerIteration(RPZTrackerParams& params, const DNSName& zoneNam } else { totremove++; - SLOG(g_log << (g_logRPZChanges ? Logger::Info : Logger::Debug) << "Had removal of " << resourceRecord.d_name << " from RPZ zone " << zoneName << endl, - logger->info(g_logRPZChanges ? Logr::Info : Logr::Debug, "Remove from RPZ zone", "name", Logging::Loggable(resourceRecord.d_name))); + logger->info(g_logRPZChanges ? Logr::Info : Logr::Debug, "Remove from RPZ zone", "name", Logging::Loggable(resourceRecord.d_name)); RPZRecordToPolicy(resourceRecord, newZone, false, params.defpol, params.defpolOverrideLocal, params.maxTTL, logger); } } @@ -659,8 +637,7 @@ static bool RPZTrackerIteration(RPZTrackerParams& params, const DNSName& zoneNam } else { totadd++; - SLOG(g_log << (g_logRPZChanges ? Logger::Info : Logger::Debug) << "Had addition of " << resourceRecord.d_name << " to RPZ zone " << zoneName << endl, - logger->info(g_logRPZChanges ? Logr::Info : Logr::Debug, "Addition to RPZ zone", "name", Logging::Loggable(resourceRecord.d_name))); + logger->info(g_logRPZChanges ? Logr::Info : Logr::Debug, "Addition to RPZ zone", "name", Logging::Loggable(resourceRecord.d_name)); RPZRecordToPolicy(resourceRecord, newZone, true, params.defpol, params.defpolOverrideLocal, params.maxTTL, logger); } } @@ -671,8 +648,7 @@ static bool RPZTrackerIteration(RPZTrackerParams& params, const DNSName& zoneNam newZone->setSOA(std::move(dnsRecord)); params.zoneXFRParams.soaRecordContent = std::move(currentSR); } - SLOG(g_log << Logger::Info << "Had " << totremove << " RPZ removal" << addS(totremove) << ", " << totadd << " addition" << addS(totadd) << " for " << zoneName << " New serial: " << params.soaRecordContent->d_st.serial << endl, - logger->info(Logr::Info, "RPZ mutations", "removals", Logging::Loggable(totremove), "additions", Logging::Loggable(totadd), "newserial", Logging::Loggable(params.zoneXFRParams.soaRecordContent->d_st.serial))); + logger->info(Logr::Info, "RPZ mutations", "removals", Logging::Loggable(totremove), "additions", Logging::Loggable(totadd), "newserial", Logging::Loggable(params.zoneXFRParams.soaRecordContent->d_st.serial)); newZone->setSerial(params.zoneXFRParams.soaRecordContent->d_st.serial); newZone->setRefresh(params.zoneXFRParams.soaRecordContent->d_st.refresh); setRPZZoneNewState(polName, params.zoneXFRParams.soaRecordContent->d_st.serial, newZone->size(), false, fullUpdate); @@ -682,8 +658,7 @@ static bool RPZTrackerIteration(RPZTrackerParams& params, const DNSName& zoneNam since they might have been updated by another RPZ IXFR tracker thread. */ if (luaconfsLocal->generation != configGeneration) { - SLOG(g_log << Logger::Info << "A more recent configuration has been found, stopping the existing RPZ update thread for " << zoneName << endl, - logger->info(Logr::Info, "A more recent configuration has been found, stopping the existing RPZ update thread")); + logger->info(Logr::Info, "A more recent configuration has been found, stopping the existing RPZ update thread"); return false; } g_luaconfs.modify([zoneIdx = params.zoneXFRParams.zoneIdx, &newZone](LuaConfigItems& lci) { @@ -696,12 +671,10 @@ static bool RPZTrackerIteration(RPZTrackerParams& params, const DNSName& zoneNam refresh = std::max(params.zoneXFRParams.refreshFromConf != 0 ? params.zoneXFRParams.refreshFromConf : newZone->getRefresh(), 1U); } catch (const std::exception& e) { - SLOG(g_log << Logger::Error << "Error while applying the update received over XFR for " << zoneName << ", skipping the update: " << e.what() << endl, - logger->error(Logr::Error, e.what(), "Exception while applying the update received over XFR, skipping", "exception", Logging::Loggable("std::exception"))); + logger->error(Logr::Error, e.what(), "Exception while applying the update received over XFR, skipping", "exception", Logging::Loggable("std::exception")); } catch (const PDNSException& e) { - SLOG(g_log << Logger::Error << "Error while applying the update received over XFR for " << zoneName << ", skipping the update: " << e.reason << endl, - logger->error(Logr::Error, e.reason, "Exception while applying the update received over XFR, skipping", "exception", Logging::Loggable("PDNSException"))); + logger->error(Logr::Error, e.reason, "Exception while applying the update received over XFR, skipping", "exception", Logging::Loggable("PDNSException")); } return true; } @@ -717,8 +690,7 @@ void RPZIXFRTracker(RPZTrackerParams params, uint64_t configGeneration) /* we can _never_ modify this zone directly, we need to do a full copy then replace the existing zone */ std::shared_ptr oldZone = g_luaconfs.getLocal()->dfe.getZone(params.zoneXFRParams.zoneIdx); if (!oldZone) { - SLOG(g_log << Logger::Error << "Unable to retrieve RPZ zone with index " << params.zoneIdx << " from the configuration, exiting" << endl, - logger->error(Logr::Error, "Unable to retrieve RPZ zone from configuration", "index", Logging::Loggable(params.zoneXFRParams.zoneIdx))); + logger->error(Logr::Error, "Unable to retrieve RPZ zone from configuration", "index", Logging::Loggable(params.zoneXFRParams.zoneIdx)); return; } diff --git a/pdns/recursordist/secpoll-recursor.cc b/pdns/recursordist/secpoll-recursor.cc index db8e6fe12..78a2e3945 100644 --- a/pdns/recursordist/secpoll-recursor.cc +++ b/pdns/recursordist/secpoll-recursor.cc @@ -59,8 +59,7 @@ void doSecPoll(time_t* last_secpoll, Logr::log_t log) auto vlog = log->withValues("version", Logging::Loggable(pkgv), "query", Logging::Loggable(query)); if (vStateIsBogus(state)) { - SLOG(g_log << Logger::Error << "Failed to retrieve security status update for '" + pkgv + "' on '" << query << "', DNSSEC validation result was Bogus!" << endl, - vlog->info(Logr::Error, "Failed to retrieve security status update", "validationResult", Logging::Loggable(vStateToString(state)))); + vlog->info(Logr::Error, "Failed to retrieve security status update", "validationResult", Logging::Loggable(vStateToString(state))); if (g_security_status == 1) { // If we were OK, go to unknown g_security_status = 0; } @@ -68,8 +67,7 @@ void doSecPoll(time_t* last_secpoll, Logr::log_t log) } if (res == RCode::NXDomain && !isReleaseVersion(pkgv)) { - SLOG(g_log << Logger::Warning << "Not validating response for security status update, this is a non-release version" << endl, - vlog->info(Logr::Warning, "Not validating response for security status update, this is a non-release version")); + vlog->info(Logr::Warning, "Not validating response for security status update, this is a non-release version"); return; } @@ -81,23 +79,19 @@ void doSecPoll(time_t* last_secpoll, Logr::log_t log) } catch (const PDNSException& pe) { g_security_status = security_status; - SLOG(g_log << Logger::Warning << "Failed to retrieve security status update for '" << pkgv << "' on '" << query << "': " << pe.reason << endl, - vlog->error(Logr::Warning, pe.reason, "Failed to retrieve security status update")); + vlog->error(Logr::Warning, pe.reason, "Failed to retrieve security status update"); return; } auto rlog = vlog->withValues("securitymessage", Logging::Loggable(security_message), "status", Logging::Loggable(security_status)); if (g_security_status != 1 && security_status == 1) { - SLOG(g_log << Logger::Warning << "Polled security status of version " << pkgv << ", no known issues reported: " << security_message << endl, - rlog->info(Logr::Notice, "Polled security status of version, no known issues reported")); + rlog->info(Logr::Notice, "Polled security status of version, no known issues reported"); } if (security_status == 2) { - SLOG(g_log << Logger::Error << "PowerDNS Security Update Recommended: " << security_message << endl, - rlog->info(Logr::Error, "PowerDNS Security Update Recommended")); + rlog->info(Logr::Error, "PowerDNS Security Update Recommended"); } if (security_status == 3) { - SLOG(g_log << Logger::Error << "PowerDNS Security Update Mandatory: " << security_message << endl, - rlog->info(Logr::Error, "PowerDNS Security Update Mandatory")); + rlog->info(Logr::Error, "PowerDNS Security Update Mandatory"); } g_security_status = security_status; diff --git a/pdns/recursordist/syncres.cc b/pdns/recursordist/syncres.cc index 127a3fbf0..debd38ead 100644 --- a/pdns/recursordist/syncres.cc +++ b/pdns/recursordist/syncres.cc @@ -6153,28 +6153,23 @@ int directResolve(const DNSName& qname, const QType qtype, const QClass qclass, res = resolver.beginResolve(qname, qtype, qclass, ret, 0); } catch (const PDNSException& e) { - SLOG(g_log << Logger::Warning << "Failed to resolve " << qname << ", got pdns exception: " << e.reason << endl, - log->error(Logr::Warning, e.reason, msg, "exception", Logging::Loggable("PDNSException"))); + log->error(Logr::Warning, e.reason, msg, "exception", Logging::Loggable("PDNSException")); ret.clear(); } catch (const ImmediateServFailException& e) { - SLOG(g_log << Logger::Warning << "Failed to resolve " << qname << ", got ImmediateServFailException: " << e.reason << endl, - log->error(Logr::Warning, e.reason, msg, "exception", Logging::Loggable("ImmediateServFailException"))); + log->error(Logr::Warning, e.reason, msg, "exception", Logging::Loggable("ImmediateServFailException")); ret.clear(); } catch (const PolicyHitException& e) { - SLOG(g_log << Logger::Warning << "Failed to resolve " << qname << ", got a policy hit" << endl, - log->info(Logr::Warning, msg, "exception", Logging::Loggable("PolicyHitException"))); + log->info(Logr::Warning, msg, "exception", Logging::Loggable("PolicyHitException")); ret.clear(); } catch (const std::exception& e) { - SLOG(g_log << Logger::Warning << "Failed to resolve " << qname << ", got STL error: " << e.what() << endl, - log->error(Logr::Warning, e.what(), msg, "exception", Logging::Loggable("std::exception"))); + log->error(Logr::Warning, e.what(), msg, "exception", Logging::Loggable("std::exception")); ret.clear(); } catch (...) { - SLOG(g_log << Logger::Warning << "Failed to resolve " << qname << ", got an exception" << endl, - log->info(Logr::Warning, msg)); + log->info(Logr::Warning, msg); ret.clear(); } @@ -6208,35 +6203,28 @@ int SyncRes::getRootNS(struct timeval now, asyncresolve_t asyncCallback, unsigne } } 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"))); + log->error(Logr::Error, e.reason, msg, "exception", Logging::Loggable("PDNSException")); } 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"))); + log->error(Logr::Error, e.reason, msg, "exception", Logging::Loggable("ImmediateServFailException")); } catch (const PolicyHitException& policyHit) { - SLOG(g_log << Logger::Error << "Failed to update . records, got a policy hit" << endl, - log->info(Logr::Error, msg, "exception", Logging::Loggable("PolicyHitException"), - "policyName", Logging::Loggable(resolver.d_appliedPolicy.getName()))); + log->info(Logr::Error, msg, "exception", Logging::Loggable("PolicyHitException"), + "policyName", Logging::Loggable(resolver.d_appliedPolicy.getName())); ret.clear(); } 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"))); + log->error(Logr::Error, e.what(), msg, "exception", Logging::Loggable("std::exception")); } catch (...) { - SLOG(g_log << Logger::Error << "Failed to update . records, got an exception" << endl, - log->info(Logr::Error, msg)); + log->info(Logr::Error, msg); } if (res == 0) { - SLOG(g_log << Logger::Debug << "Refreshed . records" << endl, - log->info(Logr::Debug, "Refreshed . records")); + log->info(Logr::Debug, "Refreshed . records"); } else { - SLOG(g_log << Logger::Warning << "Failed to update root NS records, RCODE=" << res << endl, - log->info(Logr::Warning, msg, "rcode", Logging::Loggable(res))); + log->info(Logr::Warning, msg, "rcode", Logging::Loggable(res)); } return res; } diff --git a/pdns/recursordist/validate-recursor.cc b/pdns/recursordist/validate-recursor.cc index ebf869547..331927312 100644 --- a/pdns/recursordist/validate-recursor.cc +++ b/pdns/recursordist/validate-recursor.cc @@ -21,8 +21,7 @@ bool warnIfDNSSECDisabled(const string& msg) if (g_dnssecmode == DNSSECMode::Off) { if (!msg.empty()) { auto log = g_slog->withName("config"); - SLOG(g_log << Logger::Warning << msg << endl, - log->info(Logr::Warning, msg)); + log->info(Logr::Warning, msg); } return true; } @@ -69,12 +68,10 @@ bool updateTrustAnchorsFromFile(const std::string& fname, map& } } if (dsAnchors == newDSAnchors) { - SLOG(g_log << Logger::Debug << "Read Trust Anchors from file, no changes detected" << endl, - log->info(Logr::Debug, "Read Trust Anchors from file, no changes detected")); + log->info(Logr::Debug, "Read Trust Anchors from file, no changes detected"); return false; } - SLOG(g_log << Logger::Info << "Read changed Trust Anchors from file, updating" << endl, - log->info(Logr::Info, "Read changed Trust Anchors from file, updating")); + log->info(Logr::Info, "Read changed Trust Anchors from file, updating"); dsAnchors = std::move(newDSAnchors); return true; }