From 897c8fd3bd46e8148926b39094f34883fe33ae1c Mon Sep 17 00:00:00 2001 From: Otto Moerbeek Date: Mon, 12 Jun 2023 11:02:02 +0200 Subject: [PATCH] Don't double print and delint --- pdns/recursordist/rec-main.cc | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/pdns/recursordist/rec-main.cc b/pdns/recursordist/rec-main.cc index c63874c841..8ff4e4d545 100644 --- a/pdns/recursordist/rec-main.cc +++ b/pdns/recursordist/rec-main.cc @@ -905,7 +905,6 @@ static const char* toTimestampStringMilli(const struct timeval& tval, std::array return buf.data(); } -#define HAVE_SYSTEMD #ifdef HAVE_SYSTEMD static void loggerSDBackend(const Logging::Entry& entry) { @@ -928,20 +927,19 @@ static void loggerSDBackend(const Logging::Entry& entry) "tid", "unit", "user_unit", - "object_pid" - }; + "object_pid"}; // First map SL priority to syslog's Urgency - Logger::Urgency u = entry.d_priority ? Logger::Urgency(entry.d_priority) : Logger::Info; - if (u > s_logUrgency) { + Logger::Urgency urgency = entry.d_priority != 0 ? Logger::Urgency(entry.d_priority) : Logger::Info; + if (urgency > s_logUrgency) { // We do not log anything if the Urgency of the message is lower than the requested loglevel. // Not that lower Urgency means higher number. return; } // We need to keep the string in mem until sd_journal_sendv has ben called vector strings; - auto appendKeyAndVal = [&strings](const string& k, const string& v) { - strings.emplace_back(k + "=" + v); + auto appendKeyAndVal = [&strings](const string& key, const string& value) { + strings.emplace_back(key + "=" + value); }; appendKeyAndVal("MESSAGE", entry.message); if (entry.error) { @@ -960,7 +958,9 @@ static void loggerSDBackend(const Logging::Entry& entry) key.append(value.first); appendKeyAndVal(toUpper(key), value.second); } - appendKeyAndVal(toUpper(value.first), value.second); + else { + appendKeyAndVal(toUpper(value.first), value.second); + } } // Thread id filled in by backend, since the SL code does not know about RecursorThreads // We use the Recursor thread, other threads get id 0. May need to revisit. @@ -968,9 +968,9 @@ static void loggerSDBackend(const Logging::Entry& entry) vector iov; iov.reserve(strings.size()); - for (const auto& s : strings) { + for (const auto& str : strings) { // iovec has no 2 arg constructor, so make it explicit - iov.emplace_back(iovec{const_cast(reinterpret_cast(s.data())), s.size()}); + iov.emplace_back(iovec{const_cast(reinterpret_cast(str.data())), str.size()}); // NOLINT: it's the API } sd_journal_sendv(iov.data(), static_cast(iov.size())); } -- 2.47.2