From 6c01a00972dc062c2e8ee369cf5f036328f995ee Mon Sep 17 00:00:00 2001 From: Charles-Henri Bruyand Date: Fri, 30 Apr 2021 16:30:49 +0200 Subject: [PATCH] do not dynamically allocate entries. backend currently doesn't do anything other than printing the entry for now --- pdns/pdns_recursor.cc | 16 ++++++++-------- pdns/recursordist/logging.cc | 16 ++++++++-------- pdns/recursordist/logging.hh | 2 +- 3 files changed, 17 insertions(+), 17 deletions(-) diff --git a/pdns/pdns_recursor.cc b/pdns/pdns_recursor.cc index 87ec618245..4c8415fd59 100644 --- a/pdns/pdns_recursor.cc +++ b/pdns/pdns_recursor.cc @@ -5394,24 +5394,24 @@ catch(...) { -static void loggerBackend(std::unique_ptr entry) { +static void loggerBackend(const Logging::Entry& entry) { static thread_local std::stringstream buf; buf.str(""); - buf << "msg=" << std::quoted(entry->message); - if (entry->error) { - buf << " oserror=" << std::quoted(entry->error.get()); + buf << "msg=" << std::quoted(entry.message); + if (entry.error) { + buf << " oserror=" << std::quoted(entry.error.get()); } - if (entry->name) { - buf << " subsystem=" << std::quoted(entry->name.get()); + if (entry.name) { + buf << " subsystem=" << std::quoted(entry.name.get()); } - for (auto const& v: entry->values) { + for (auto const& v: entry.values) { buf << " "; buf << v.first << "=" << std::quoted(v.second); } - g_log << Logger::Urgency(entry->level) << buf.str() << endl; + g_log << Logger::Urgency(entry.level) << buf.str() << endl; } diff --git a/pdns/recursordist/logging.cc b/pdns/recursordist/logging.cc index 7a81bd5818..7b058c4bcc 100644 --- a/pdns/recursordist/logging.cc +++ b/pdns/recursordist/logging.cc @@ -46,18 +46,18 @@ namespace Logging if (_level > _verbosity) { return ; } - auto entry = std::unique_ptr(new Entry()); - entry->level = _level; - entry->name = _name; - entry->message = msg; - entry->error = err; + Entry entry; + entry.level = _level; + entry.name = _name; + entry.message = msg; + entry.error = err; auto parent = _parent; - entry->values.insert(_values.begin(), _values.end()); + entry.values.insert(_values.begin(), _values.end()); while (parent) { - entry->values.insert(parent->_values.begin(), parent->_values.end()); + entry.values.insert(parent->_values.begin(), parent->_values.end()); parent = parent->_parent; } - _callback(std::move(entry)); + _callback(entry); } void Logger::error(int err, const std::string& msg) diff --git a/pdns/recursordist/logging.hh b/pdns/recursordist/logging.hh index 71c7aa781d..73b1d71ade 100644 --- a/pdns/recursordist/logging.hh +++ b/pdns/recursordist/logging.hh @@ -64,7 +64,7 @@ namespace Logging { // template <> // Loggable::Loggable(const std::string& v): _t(v) {} - typedef void(*EntryLogger)(std::unique_ptr); + typedef void(*EntryLogger)(const Entry&); class Logger: public Logr::Logger, public std::enable_shared_from_this { -- 2.47.2